带optirun的IPython笔记本电脑

2024-10-02 00:32:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从IPython笔记本电脑上用nvidiaoptimus(大黄蜂)在Linux笔记本上运行pycuda。通常,我可以通过输入optirun python my_pycuda_script.py来运行python脚本

但是如果我启动optirun ipython notebook然后打开一个笔记本,一个新的内核就会启动,我就不能再运行pycuda了。{I发现这是一个很难看的脚本,但我发现这个脚本很难看。有更好的方法吗?也许有一个神奇的功能,所以只有相关的笔记本电脑才用optirun启动?在

谢谢你的帮助!在


Tags: pypycuda脚本mylinuxipythonscript笔记本
1条回答
网友
1楼 · 发布于 2024-10-02 00:32:09

我刚从github:data_science_workspace找到了一个解决方案。在

GPU support for Jupyter:

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. 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 the argv array:

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

但是在我的电脑里,kernel.json在:~/miniconda3/envs/nn/share/jupyter/kernels/python3下面。在

我的状态信息:

^{pr2}$

希望这就是你需要的:-)。在

相关问题 更多 >

    热门问题