Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
doku:python [2023/04/17 08:14] – [Optional: execute conda hooks on login] katrin | doku:python [2023/06/19 08:33] – katrin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Python ====== | + | ====== Python |
+ | |||
+ | ===== (Conda) Quickstart ===== | ||
+ | |||
+ | To install a new environment start with creating an environment yaml file and store it in a safe location (ideally in your source code repository). This step is optional but we really recommend it so you and everyone in your team is able to produce the same python environment. | ||
+ | < | ||
+ | name: my-env | ||
+ | dependencies: | ||
+ | - python=3.10 | ||
+ | - tensorflow-gpu=2.6.0 | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | # load the miniconda package | ||
+ | $ module load miniconda3 | ||
+ | |||
+ | # executes bash hooks for the tool to function | ||
+ | # and enters the " | ||
+ | $ eval " | ||
+ | |||
+ | # create your environment via environment file | ||
+ | (base) $ conda create -n my-env --file my_env.yaml | ||
+ | |||
+ | # after creation you can activate the environment to run code in it | ||
+ | (base) $ conda activate my-env | ||
+ | |||
+ | # test python version to make sure we have the right one | ||
+ | (my-env) $ python --version | ||
+ | Python 3.10.11 | ||
+ | </ | ||
+ | |||
+ | You can now start developing and even just use the environment in a slurm script | ||
+ | |||
+ | < | ||
+ | # | ||
+ | |||
+ | #SBATCH --job-name=slurm_conda_example | ||
+ | #SBATCH --time 00-00: | ||
+ | #SBATCH --ntasks=2 | ||
+ | #SBATCH --mem=2GB | ||
+ | |||
+ | # modify SBATCH options according to needs | ||
+ | |||
+ | # see "Setup Conda" above or consult " | ||
+ | module load MINICONDA3_PACKAGE_NAME | ||
+ | eval " | ||
+ | conda activate myenv | ||
+ | |||
+ | # print out some info of the python executable in use | ||
+ | # this should point to the python version from " | ||
+ | which python | ||
+ | python --version | ||
+ | </ | ||
+ | |||
+ | ==== FAQ ==== | ||
+ | |||
+ | **I see the error ''' | ||
+ | |||
+ | The default for sbatch is to use the current user environment and start the job in the context of this environment. Since conda is depending on environment variables being setup correctly you need to ake sure to start the job script from a clean environment. Alternatively you can also use sbatch with the ''' | ||
+ | |||
+ | ====== Deprecated Information (work in progress) | ||
===== Python Installations ===== | ===== Python Installations ===== | ||
Line 36: | Line 96: | ||
==== Setup Conda ==== | ==== Setup Conda ==== | ||
- | To load '' | + | To use the '' |
<code bash> | <code bash> | ||
- | # VSC-4 | + | module load miniconda3 |
- | module load miniconda3/ | + | |
- | + | ||
- | # VSC-5 | + | |
- | module load miniconda3/ | + | |
</ | </ | ||