Using Python - chunxxc/GPU-Server-Handbook GitHub Wiki
Python
Python 3.7 is selected as the prior when type python3
on server, while python3.6, python3.8 and python3.9 is still an alternative but need to trigger by $pythonX.Y
(Tensorflow and Pytorch are installed only for default python3). Just type python
will give you an out-of-date python2.7 session.
Use virtual environment
Using a virtual environment is a win-win solution for server users and to parallel multiple projects as it isolates project-oriented python dependencies. The two most popular ways to create such env are:
first, manually create a folder in your directory with
$mkdir PATH_TO_YOUR_VENV
- with python3
$python3 -m venv --system-site-packages PATH_TO_YOUR_VENV
:exclamation: add the --system-site-packages
option only if you want to use TensorFlow2.3 and Pytorch with optimized GPU performance.
Once it finished initialization, activate it with $source PATH_TO_YOUR_VENV/bin/activate
. While it remains activated, all packages/libraries installed are kept inside this environment. Deactivate the environment with $deactivate
.
- with conda
if you want to use anaconda3, install it locally follow this guide
The anaconda environment is more than a python environment as it is a system package manager, but it is as easy to use as the python one. Create the environment with:
$conda create --name YOUR_ENV_NAME
similarly, activate the env with $conda activate YOUR_ENV_NAME
and deactivate with the command $conda deactivate
:exclamation: for how to use the system-wide installed packages, read this issue