How to make Jupyter Notebook to run on GPU?

2020-05-19 06:17发布

问题:

In Google Collab you can choose your notebook to run on cpu or gpu environment. Now I have a laptop with NVDIA Cuda Compatible GPU 1050, and latest anaconda. How to have similiar feature to the collab one where I can simply make my python to run on GPU?

回答1:

I am answering my own question. Easiest way to do is use connect to Local Runtime (https://research.google.com/colaboratory/local-runtimes.html) then select hardware accelerator as GPU as shown in (https://medium.com/deep-learning-turkey/google-colab-free-gpu-tutorial-e113627b9f5d).



回答2:

I've written a medium article about how to set up Jupyterlab in Docker (and Docker Swarm) that accesses the GPU via CUDA in PyTorch or Tensorflow.

Set up your own GPU-based Jupyter

I'm clear that you don't search for a solution with Docker, however, it saves you a lot of time when using an existing Dockerfile with plenty of packages required for statistics and ML.



回答3:

I have OpenCL SDK for Intel setup for my Windows 10, 64 bit system. I have also installed PyOpenCL for Python 3.7. I didn't install it with conda but pip with the WHL file. I can use it with IDEL with no problem. To use PyOpenCL with Jupyter notebook and Spyder (Anaconda3). I did further with the following:

  1. Find Anaconda Powershell Prompt (Anaconda3) from Windows start menu and run it as administrator (to avoid user permission error.)

  2. Try and update like so:

    (base) PS C:\WINDOWS\system32> conda update -n base conda -c anaconda

( Warning: this may take some time if it has not been updated for some time..) type in y to continue when asked.

Given that is done with no error, now you are ready to install PyOpenCL:

(base) PS C:\WINDOWS\system32> conda install -c conda-forge pyopencl

Enter y to proceed when asked.

(This will be quick!)

Now you can start Spyder or Jupyter to test it.

import pyopencl as cl

Giving no error, you are all set! And that is. It has been tested working with Jupyter and Spyder 3 on Windows 10, 64 bit. I hope you will find this helpful.



标签: gpu