test_gpu_acceleration_pythonl
test_gpu_acceleration_pythonl
- tensorflow-2.18.0 -> Ptython version 3.9-3.12 -> cuDNN 9.3-> CUDA 12.5
- install all of them with yay and that's it
- Details -> https://www.tensorflow.org/install/source#sample_session
- A python version manager https://github.com/pyenv/pyenv
- So you can install and manage multiple python versions like nvm or
sdkman
- ### Using Nvidia GPU on a jupyter lab
- Make sure you installed nvidia drivers, nvidia cuda toolkit, cuDNN
and a compatible version of python.
- Configure the necessary environment variables
collapsed:: true
-
```shell
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/opt/cuda/nvvm/lib64:$LD_LIBRARY_PATH
export XLA_FLAGS=--xla_gpu_cuda_data_dir=/opt/cuda
```
- in my case cuda was installed on `/opt/cuda`
- Using [pyenv](ttps://github.com/pyenv/pyenv) to make sure you're
using the [right version](https://www.tensorflow.org/install/source#sample_session)
for your cuda version
- in your root project dir execute `pyenv local 3.12`
- Now create a new python virtual environment with `python -m venv
my_notebook_env`
- Activate the virtual env with `source my_notebook_env/bin/activate`
- Optional upgrade pip version with `pip install --upgrade pip`
- Install the required libraries `pip install tensorflow jupyterlab `
- Run `jupyter lab`
- Sample code to test:
-
```python
import tensorflow as tf
model.compile(optimizer='adam',
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy'])