This paper introduces the R package sgmcmc; which can be used for Bayesian inference on problems with large datasets using stochastic gradient Markov chain Monte Carlo (SGMCMC). Traditional Markov chain Monte Carlo (MCMC) methods, such as Metropolis-Hastings, are known to run prohibitively slowly as the dataset size increases. SGMCMC solves this issue by only using a subset of data at each iteration. SGMCMC requires calculating gradients of the log likelihood and log priors, which can be time consuming and error prone to perform by hand. The sgmcmc package calculates these gradients itself using automatic differentiation, making the implementation of these methods much easier. To do this, the package uses the software library TensorFlow, which has a variety of statistical distributions and mathematical operations as standard, meaning a wide class of models can be built using this framework. SGMCMC has become widely adopted in the machine learning literature, but less so in the statistics community. We believe this may be partly due to lack of software; this package aims to bridge this gap.of the major advantages of sgmcmc is that gradients are calculated within the package using automatic differentiation (Griewank and Walther, 2008). This means that users need only specify the log likelihood function and log prior for their model. The package calculates the gradients using TensorFlow (TensorFlow Development Team, 2015), which has recently been made available for R (Allaire et al., 2016). TensorFlow is an efficient library for numerical computation which can take advantage of a wide variety of architectures, as such, sgmcmc keeps much of this efficiency. Both sgmcmc and TensorFlow are available on CRAN, so sgmcmc can be installed by using the standard install.packages function. Though after the TensorFlow package has been installed, the extra install tensorflow() function needs to be run, which installs the required Python implementation of TensorFlow. 1 The sgmcmc package also has a website with vignettes, tutorials and an API reference. 2 SGMCMC methods have become popular in the machine learning literature but less so in the statistics community. We partly attribute this to the lack of available software. To the best of our knowledge, there are currently no R packages available for SGMCMC, probably the most popular programming language within the statistics community. The only package we are aware of which implements scalable MCMC is the Python package edward (Tran et al., 2016). This package implements both SGLD and SGHMC, but does not implement SGNHT or any of the control variate methods.Section 2 introduces MCMC and discusses the software currently available for implementing MCMC algorithms, we discuss the scenarios where sgmcmc is designed to be used. In Section 3 we review the methodology behind the SGMCMC methods implemented in sgmcmc. Section 4 provides a brief introduction to TensorFlow. Section 5 overviews the structure of the package, as well as details of how the algorithms are implemented. Section 6...