IPython laptop with optirun

I want to run pycuda from an IPython laptop on a Linux laptop with NVIDIA Optimus (bumblebee). I can usually run a python script by typing optirun python my_pycuda_script.py

But if I run optirun ipython notebook , and then open notepad, a new kernel will start, and I can no longer run pycuda. I found that if I replaced the python executable with a shell script that calls optirun new_location_of_python , it works - but it's a pretty ugly hack. Is there a better way to do this? Maybe with a magic function, so that with optirun only the corresponding laptops are launched?

Thanks for any help!

+6
source share
1 answer

I just found a solution from github: data_science_workspace .

GPU support for Jupyter:

For Linux computers with optimizations, you must create a kernel that will be invoked with optirun in order to be able to use GPU acceleration. To do this, go to the following folder:

cd ~/.local/share/jupyter/kernels/

then edit the python3/kernel.json file to add "optirun" as the first entry in the argv array:

 { "language": "python", "display_name": "Python 3", "argv": [ "optirun", "/home/fabien/.conda/envs/data_science/bin/python", "-m", "ipykernel", "-f", "{connection_file}" ] } 

But on my computer, kernel.json is under: ~/miniconda3/envs/nn/share/jupyter/kernels/python3 .

My cond info:

 $ conda info user-agent : conda/4.3.30 requests/2.14.2 CPython/3.6.1 Linux/4.9.79-1-MANJARO arch/Manjaro glibc/2.26 

I hope you need this :-).

+1
source

Source: https://habr.com/ru/post/970953/


All Articles