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
doku:python [2024/02/22 16:38] katrindoku:python [2024/03/19 14:24] (current) katrin
Line 38: Line 38:
 # create your environment via environment file # create your environment via environment file
 # this will place the environment in your ~/.conda/envs folder # this will place the environment in your ~/.conda/envs folder
-# note: make sure to use "conda >env< create" - "conda create" is a different command +# note:  
-(base) $ conda env create -n my-env --file my_env.yaml+#  - make sure to use "conda >env< create" - "conda create" is a different command 
 +#  - the name is taken from the yaml file; a custom name can be specified with "-n my-custom-name"  
 +(base) $ conda env create --file my_env.yaml
  
 # after creation you can activate the environment to run code in it # after creation you can activate the environment to run code in it
Line 72: Line 74:
 </code> </code>
  
-==== More info about Conda ====+===== More info about Conda =====
  
 For more information about conda check-out the conda notebook of the python4HPC training material: [[https://gitlab.tuwien.ac.at/vsc-public/training/python4hpc/-/blob/main/D1_02_env_03_conda.ipynb|python4HPC Conda Environments]] For more information about conda check-out the conda notebook of the python4HPC training material: [[https://gitlab.tuwien.ac.at/vsc-public/training/python4hpc/-/blob/main/D1_02_env_03_conda.ipynb|python4HPC Conda Environments]]
  
-==== FAQ ====+===== FAQ =====
  
   * **'''eval "$(conda shell.bash hook)"''' fails with '''CommandNotFoundError ...'''**   * **'''eval "$(conda shell.bash hook)"''' fails with '''CommandNotFoundError ...'''**
Line 82: Line 84:
 Make sure to use the currently provided '''miniconda3''' module via '''module load miniconda3''' Make sure to use the currently provided '''miniconda3''' module via '''module load miniconda3'''
  
-  * **I dont get the right python version and packages** / **I see the error '''ModuleNotFoundError: No module named "conda"''' in my slurm job logfile** - **What is wrong>?**+  * **I dont get the right python version and packages in my slurm batch file environment** - **What is wrong>?**
  
-The default for sbatch is to use the current user environment and start the job in the context of this environmentSince conda is depending on environment variables being setup correctly you need to make sure to start the job script from a clean environment. +Make sure that one of the first things in your sbatch script is loading the miniconda3 package '''module load miniconda3''' and that you execute '''eval "$(conda shell.bash hook)"''' before using any other conda commands. 
 + 
 +  * **I don't get GPU/CUDA enabled packages when installing a conda environment** / **I get conda installation errors when i select GPU/CUDA enabled builds for my conda environment*** 
 + 
 +In order to install packages from conda-forge that require CUDA on machine that does not have GPUs you have to set an environment variable before creating the conda environment: 
 +<code> 
 +name: my-pytorch-gpu-env 
 +channels: 
 +  - pytorch 
 +  - conda-forge 
 +  - defaults 
 +dependencies: 
 +  - python=3.12 
 +  - pytorch=2.2.*=*cuda11.8* 
 +</code> 
 + 
 +<code> 
 +# for example if you use cuda 11.8 
 +CONDA_OVERRIDE_CUDA="11.8" conda env create -n my-pytorch-gpu-env --file my-pytorch-gpu-env.yaml 
 +</code>
  
-Alternatively you can also use sbatch with the '''--export=NONE''' argument from commandline or add an sbatch directive in your job script: "#SBATCH --export=NONE" 
  
 ====== Deprecated Information (work in progress) ====== ====== Deprecated Information (work in progress) ======
  • doku/python.1708619919.txt.gz
  • Last modified: 2024/02/22 16:38
  • by katrin