{"id":374,"date":"2016-12-07T11:41:57","date_gmt":"2016-12-07T10:41:57","guid":{"rendered":"https:\/\/wpethzprd.ethz.ch\/isgdmath\/?p=374"},"modified":"2025-10-13T13:52:32","modified_gmt":"2025-10-13T11:52:32","slug":"tensorflow","status":"publish","type":"post","link":"https:\/\/blogs.ethz.ch\/isgdmath\/tensorflow\/","title":{"rendered":"Tensorflow"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.tensorflow.org\/guide\/gpu\">https:\/\/www.tensorflow.org\/guide\/gpu<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.astral.sh\/uv\/\">https:\/\/docs.astral.sh\/uv\/<\/a><\/li>\n<\/ul>\n\n\n\n<p>To be able to use tensorflow you need to install it for your project. We recommend to use <code>uv<\/code> for creating your tensorflow python project.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Setup your project<\/h3>\n\n\n\n<p><code>uv<\/code> will create and use a python virtual environment transparently so there is no need to create one seperatly. Use the storage on <code>\/scratch\/userdata\/$USER<\/code> for your project, this is on the local disk of the ada-Xs as not all have the same python versions so the virtual environment must be recreated for every ada-X.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Initialize the project<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>export UV_NO_CACHE=1\ncd \/scratch\/userdata\/$USER\n\nuv init new-uv-project<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install tensorflow and cuda in the project<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/scratch\/userdata\/$USER\/new-uv-project\nuv add tensorflow&#091;and-cuda]\n\n# if you didn't set UV_NO_CACHE your cache could be big.\nuv cache clean<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Run your python code<\/h4>\n\n\n\n<p>To run you need to use <code>uv<\/code> you cannot simply use python as this will not load the virtual environment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/scratch\/userdata\/$USER\/new-uv-project\nuv run main.py<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<!--more-->\n\n\n\n<ul class=\"wp-block-list\">\n<li>As over time the central clients will have different python versions you need to reinitialize the virtual environment on each client you want to work on.<\/li>\n\n\n\n<li><code>uv<\/code> has the possibility to install the cuda libraries apart from the python code.<\/li>\n\n\n\n<li>Some cuda or tensorflow versions are not compatible with all GPUs here you find the list of GPUs installed in the central clients: <a href=\"https:\/\/blogs.ethz.ch\/isgdmath\/central-clients\/\">https:\/\/blogs.ethz.ch\/isgdmath\/central-clients\/<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>To be able to use tensorflow you need to install it for your project. We recommend to use uv for creating your tensorflow python project. Setup your project uv will create and use a python virtual environment transparently so there is no need to create one seperatly. Use the storage on \/scratch\/userdata\/$USER for your project, [&hellip;]<\/p>\n","protected":false},"author":43853,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[198216,759],"tags":[],"class_list":["post-374","post","type-post","status-publish","format-standard","hentry","category-computing","category-linux"],"_links":{"self":[{"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/posts\/374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/users\/43853"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/comments?post=374"}],"version-history":[{"count":8,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":1776,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/posts\/374\/revisions\/1776"}],"wp:attachment":[{"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/media?parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/categories?post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/tags?post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}