technical:recipes:tensorflow-in-virtualenv

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
technical:recipes:tensorflow-in-virtualenv [2025-10-28 15:52] – [Create TensorFlow Virtualenv] thuachentechnical:recipes:tensorflow-in-virtualenv [2025-11-06 15:30] (current) – [Create TensorFlow Virtualenv] thuachen
Line 40: Line 40:
 tensorflow                    2.19.0 cpu_py312h69ecde4_53  conda-forge tensorflow                    2.19.0 cpu_py312h69ecde4_53  conda-forge
 </code> </code>
-All versions of the TensorFlow virtual environment will be stored in the directory ''$WORKDIR/sw/tensorflow''; each virtual environment must have a unique name that will become the VALET version of TensorFlow. In this tutorial, we will install the Tensorflow version 2.17.0 with and without the CUDA support. An appropriate version for the former would be ''2.17.0:cpu'' and the latter ''2.17.0:cuda'' Those versions can be translated to VALET-friendly directory names:+All versions of the TensorFlow virtual environment will be stored in the directory ''$WORKDIR/sw/tensorflow''; each virtual environment must have a unique name that will become the VALET version of TensorFlow. In this tutorial, we will install the Tensorflow version 2.17.0 with the CPU support and with CUDA support. An appropriate version for the former would be ''2.17.0:cpu'' and the latter ''2.17.0:cuda'' Those versions can be translated to VALET-friendly directory names:
  
 <code bash> <code bash>
Line 55: Line 55:
  
 <code bash> <code bash>
-[(my_workgroup:user)@login01 ~]$ conda create --prefix=${WORKDIR}/sw/tensorflow/2.19.0-cpu 'tensorflow[version=2.19.0,build=cpu_py312h69ecde4_52]' +[(my_workgroup:user)@login01 ~]$ conda create --prefix=${WORKDIR}/sw/tensorflow/2.17.0-cpu 'tensorflow[version=2.17.0,build=cpu_py310h42475c5_0]' 
-WARNING: A directory already exists at the target location '/work/workgroup/sw/tensorflow/2.19.0-cpu'+WARNING: A directory already exists at the target location '/work/workgroup/sw/tensorflow/2.17.0-cpu'
 but it is not a conda environment. but it is not a conda environment.
 Continue creating environment (y/[n])? y Continue creating environment (y/[n])? y
Line 68: Line 68:
 # To activate this environment, use # To activate this environment, use
 # #
-#     $ conda activate /work/workgroup/sw/tensorflow/2.19.0-cpu+#     $ conda activate /work/workgroup/sw/tensorflow/2.17.0-cpu
 # #
 # To deactivate an active environment, use # To deactivate an active environment, use
Line 78: Line 78:
  
 <code bash> <code bash>
-[(my_workgroup:user)@login01 ~]$ conda create --prefix=${WORKDIR}/sw/tensorflow/2.19.0-cuda 'tensorflow[version=2.19.0,build=cuda128py312hae5ec6b_202,channel=conda-forge]' +[(my_workgroup:user)@login01 ~]$ conda create --prefix=${WORKDIR}/sw/tensorflow/2.17.0-cuda 'python==3.10' -c conda-forge 
-WARNING: A directory already exists at the target location '/work/workgroup/sw/tensorflow/2.19.0-cuda'+WARNING: A directory already exists at the target location '/work/workgroup/sw/tensorflow/2.17.0-cuda'
 but it is not a conda environment. but it is not a conda environment.
 Continue creating environment (y/[n])? y Continue creating environment (y/[n])? y
Line 91: Line 91:
 # To activate this environment, use # To activate this environment, use
 # #
-#     $ conda activate /work/workgroup/sw/tensorflow/2.3.0-intel-python3.8+#     $ conda activate /work/workgroup/sw/tensorflow/2.17.0-cuda
 # #
 # To deactivate an active environment, use # To deactivate an active environment, use
Line 97: Line 97:
 #     $ conda deactivate #     $ conda deactivate
 </code> </code>
- +We will need to run the ''conda activate'' command and then install the Tensorflow with cuda: 
-Ignore that ''conda activate'' command as well. Roll back the environment changes before proceeding:+<code bash> 
 +[(my_workgroup:user)@login01 ~]$ conda activate /work/workgroup/sw/tensorflow/2.17.0-cuda 
 +(/work/workgroup/sw/tensorflow/2.17.0-cuda)[(my_workgroup:user)@login01 ~]$ pip install "tensorflow[and-cuda]==2.17.0" 
 +</code> 
 +Use ''conda deactivate'' command to exit the virtual environment. Roll back the environment changes before proceeding:
  
 <code bash> <code bash>
-[(my_workgroup:user)@login01 ~]$ vpkg_rollback +(/work/workgroup/sw/tensorflow/2.17.0-cuda)[(my_workgroup:user)@login01 ~]$ conda deactivate 
-[(my_workgroup:user)@login01 ~]$ +[(my_workgroup:user)@login01 ~]$ vpkg_rollback all
 </code> </code>
  
Line 123: Line 127:
           success: 0           success: 0
     versions:     versions:
-        "2.19.0:cpu": +        "2.17.0:cpu": 
-            description: 2.19.0 with CPU support+            description: 2.17.0 with CPU support
             dependencies:             dependencies:
                 - miniconda/25.1.1.2                 - miniconda/25.1.1.2
-        "2.19.0:cuda": +        "2.17.0:cuda": 
-            description: 2.19.0 with CUDA support+            description: 2.17.0 with CUDA support
             dependencies:             dependencies:
                 - miniconda/25.1.1.2                 - miniconda/25.1.1.2
Line 148: Line 152:
           success: 0           success: 0
     versions:     versions:
-        "2.19.0:cpu": +        "2.17.0:cpu": 
-            description: 2.19.0 with CPU support+            description: 2.17.0 with CPU support
             dependencies:             dependencies:
                 - miniconda/25.1.1.2                 - miniconda/25.1.1.2
-        "2.19.0:cuda": +        "2.17.0:cuda": 
-            description: 2.19.0 with CUDA support+            description: 2.17.0 with CUDA support
             dependencies:             dependencies:
                 - miniconda/25.1.1.2                 - miniconda/25.1.1.2
Line 175: Line 179:
 [/work/my_workgroup/sw/valet/tensorflow.vpkg_yaml] [/work/my_workgroup/sw/valet/tensorflow.vpkg_yaml]
 tensorflow               TensorFlow Python environments tensorflow               TensorFlow Python environments
-* 2.19.0:cpu              2.19.0 with GPU support +* 2.17.0:cpu              2.17.0 with GPU support 
-  2.19.0:cuda             2.19.0 with CUDA support+  2.17.0:cuda             2.17.0 with CUDA support
      
      :      :
Line 189: Line 193:
 # Setup TensorFlow virtualenv: # Setup TensorFlow virtualenv:
 # #
-vpkg_require tensorflow/2.19.0:cpu+vpkg_require tensorflow/2.17.0:cpu
  
 # #
  • technical/recipes/tensorflow-in-virtualenv.1761681138.txt.gz
  • Last modified: 2025-10-28 15:52
  • by thuachen