{"id":148695,"date":"2023-11-06T15:35:05","date_gmt":"2023-11-06T20:35:05","guid":{"rendered":"http:\/\/www.bu.edu\/tech\/?page_id=148695"},"modified":"2023-11-15T13:03:02","modified_gmt":"2023-11-15T18:03:02","slug":"pytorch-and-tensorflow","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/tech\/support\/research\/software-and-programming\/common-languages\/pytorch-and-tensorflow\/","title":{"rendered":"PyTorch and Tensorflow"},"content":{"rendered":"<p>On this page you will find instructions on using <a href=\"https:\/\/pytorch.org\/\">PyTorch<\/a> and <a href=\"https:\/\/www.tensorflow.org\/\">Tensorflow<\/a> software via your own installation or SCC modules. RCS does not intend to install newer versions of PyTorch and Tensorflow as modules, so for the latest versions you will need to install them yourself.<\/p>\n<h2>PyTorch<\/h2>\n<h3>Install for Yourself<\/h3>\n<p>PyTorch is straightforward to install in your own Python virtual environment or conda environment. Be mindful that the PyTorch installation with GPU capabilities is approximately 1GB in size. RCS does not intend to install newer versions of PyTorch within the module system, so a self-install is the way to get access to newer versions of PyTorch. The PyTorch <a href=\"https:\/\/pytorch.org\/get-started\/locally\/\">Start Locally<\/a> page provides instructions on installing PyTorch using the <em>pip<\/em> and <em>conda<\/em> tools.\u00a0 It also links to instructions for <a href=\"https:\/\/pytorch.org\/get-started\/previous-versions\/\">installing older versions<\/a>.<\/p>\n<h4>Python Virtual Environment<\/h4>\n<p>If you are using a Python virtual environment, then select the options &#8220;Linux \/ Pip \/ Python \/ CUDA 12.1&#8221; to see the appropriate installation command. The resulting installation will run on the GPU compute nodes and make use of the GPU hardware, and will also run on CPU-only nodes. The CUDA drivers on the SCC are kept up to date and the newest available CUDA version should be selected. No additional libraries are needed for CUDA support &#8211; everything required is built into the PyTorch installation.\u00a0 If you are interested in installing PyTorch for CPU usage only then select the options accordingly.<\/p>\n<p><img loading=\"lazy\" src=\"\/tech\/files\/2023\/11\/pytorch_pip-636x270.png\" alt=\"\" class=\"alignnone wp-image-148713\" width=\"523\" height=\"222\" srcset=\"https:\/\/www.bu.edu\/tech\/files\/2023\/11\/pytorch_pip-636x270.png 636w, https:\/\/www.bu.edu\/tech\/files\/2023\/11\/pytorch_pip-768x326.png 768w, https:\/\/www.bu.edu\/tech\/files\/2023\/11\/pytorch_pip.png 935w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/p>\n<h4>Conda Environment<\/h4>\n<p>For a conda environment install you can choose either to install via pip (as above) or using conda. For conda, just select the corresponding options on the PyTorch Start Locally page and run the conda command that is displayed.<\/p>\n<h3>Using SCC Modules<\/h3>\n<p>To see the available versions of PyTorch in the module system run:<\/p>\n<pre><code>module avail pytorch<\/code><\/pre>\n<p>Depending on which one you select you will have to also load a\u00a0<code>python3<\/code> module or activate a conda environment to use these PyTorch installations. The version of Python needs to match the support provided by the module. Loading a pytorch module without having a python3 module or activated conda environment will result in a message like this printing:<\/p>\n<pre><code>\r\n$ module load pytorch\/1.13.1\r\n\r\n-------------------------------------------------------------------------------\r\nWARNING: pytorch\/1.13.1 needs to be used with Python 3.7, 3.8, 3.9 or 3.10. This can be provided by a python3 module or via a conda\r\nenvironment.\r\n\r\nFor example:\r\n\r\nmodule load python3\/3.8.10\r\nmodule load pytorch\/1.13.1\r\n\r\nOR:\r\n\r\nmodule load miniconda\/4.9.2\r\nconda activate INSERT_YOUR_CONDA_ENV_HERE\r\nmodule load pytorch\/1.13.1\r\n\r\n-------------------------------------------------------------------------------\r\n<\/code><\/pre>\n<p>Once an appropriate version of Python is available you can use the PyTorch software normally from Python.<\/p>\n<h2>Tensorflow<\/h2>\n<h3>Install for Yourself<\/h3>\n<p>Tensorflow with GPU support has recently become straightforward to install in your own Python virtual environment or conda environment. Be mindful that the Tensorflow installation with GPU capabilities is approximately 1GB in size. RCS does not intend to install newer versions of Tensorflow within the module system, so a self-install is the way to get access to newer versions of Tensorflow.<\/p>\n<h4>Python Virtual Environment OR Conda Environment<\/h4>\n<p>Regardless of your use of a Python virtual environment or a conda environment you will use the <em>pip <\/em>tool for the installation. Tensorflow packages for the <em>conda<\/em> tool do exist but the available versions have tended to lag behind the ones available using pip.\u00a0 Instructions for installations using pip can be found on the <a href=\"https:\/\/www.tensorflow.org\/install\/pip#linux\">Tensorflow site<\/a>.\u00a0 Activate your virtual or conda environment, and then follow the Tensorflow instructions. For compatibility with GPU nodes and CPU-only compute nodes select the Linux tab and install the <em>tensorflow[and-cuda]<\/em> package using pip. For a CPU-only installation select the CPU tab and follow the instructions there.<\/p>\n<p><img loading=\"lazy\" src=\"\/tech\/files\/2023\/11\/tf_pip-636x241.png\" alt=\"\" class=\"alignnone wp-image-148714\" width=\"552\" height=\"209\" srcset=\"https:\/\/www.bu.edu\/tech\/files\/2023\/11\/tf_pip-636x241.png 636w, https:\/\/www.bu.edu\/tech\/files\/2023\/11\/tf_pip-768x291.png 768w, https:\/\/www.bu.edu\/tech\/files\/2023\/11\/tf_pip.png 866w\" sizes=\"(max-width: 552px) 100vw, 552px\" \/><\/p>\n<h3>Using SCC Modules<\/h3>\n<p>To see the available versions of Tensorflow in the module system run:<\/p>\n<pre><code>module avail tensorflow<\/code><\/pre>\n<p>Depending on which one you select you will have to also load a\u00a0<code>python3<\/code>module or activate a conda environment to use these Tensorflow modules. The version of Python needs to match the support provided by the module. Loading a Tensorflow module without having a python3 module or activated conda environment will result in a message similar to the one above for PyTorch modules.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On this page you will find instructions on using PyTorch and Tensorflow software via your own installation or SCC modules. RCS does not intend to install newer versions of PyTorch and Tensorflow as modules, so for the latest versions you will need to install them yourself. PyTorch Install for Yourself PyTorch is straightforward to install&#8230;<\/p>\n","protected":false},"author":1692,"featured_media":0,"parent":76567,"menu_order":14,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148695"}],"collection":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/users\/1692"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/comments?post=148695"}],"version-history":[{"count":6,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148695\/revisions"}],"predecessor-version":[{"id":148780,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148695\/revisions\/148780"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/76567"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/media?parent=148695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}