[英]IPython notebook with optirun
I want to run pycuda from an IPython notebook on a Linux laptop with NVIDIA Optimus (bumblebee). 我想用一台带有NVIDIA Optimus(bumblebee)的Linux笔记本电脑上的IPython笔记本运行pycuda。 Usually, I can get a python script running by typing
optirun python my_pycuda_script.py
通常,我可以通过输入
optirun python my_pycuda_script.py
来运行python脚本
But if I start optirun ipython notebook
and then open a notebook, a new Kernel starts and I cannot run pycuda anymore. 但是,如果我启动
optirun ipython notebook
,然后打开一个笔记本,一个新的内核启动,我不能再运行pycuda了。 I found that if I replace my python executable by a shell script that calls optirun new_location_of_python
it is working - but this is a pretty ugly hack. 我发现,如果我用调用
optirun new_location_of_python
的shell脚本替换我的python可执行文件,它就可以了 - 但这是一个非常丑陋的黑客攻击。 Is there a better way to do this? 有一个更好的方法吗? Maybe with a magic function, so that only the relevant notebooks are started with optirun?
也许有一个神奇的功能,所以只有相关的笔记本电脑是用optirun启动的?
Thanks for any help! 谢谢你的帮助!
I just found a solution from github:data_science_workspace . 我刚从github找到了一个解决方案:data_science_workspace 。
GPU support for Jupyter:
对Jupyter的GPU支持:
For computers on linux with optimus, you have to make a kernel that will be called with "optirun" to be able to use GPU acceleration.
对于使用optimus的linux上的计算机,你必须创建一个将使用“optirun”调用的内核,以便能够使用GPU加速。 For this go to the following folder:
为此,请转到以下文件夹:
cd ~/.local/share/jupyter/kernels/
then edit the file
python3/kernel.json
in order to add"optirun"
as first entry into theargv
array:然后编辑文件
python3/kernel.json
,以便将"optirun"
作为第一个条目添加到argv
数组中:
{
"language": "python",
"display_name": "Python 3",
"argv": [
"optirun",
"/home/fabien/.conda/envs/data_science/bin/python",
"-m",
"ipykernel",
"-f",
"{connection_file}"
]
}
But in my computer, the kernel.json
is under: ~/miniconda3/envs/nn/share/jupyter/kernels/python3
. 但在我的计算机中,
kernel.json
位于: ~/miniconda3/envs/nn/share/jupyter/kernels/python3
。
My conda 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
Hope this is what you need :-). 希望这是你需要的:-)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.