I want to run my code run on gpu in windows 10, like for google colab, we can just change the runtime option which is pretty easy to do to shift to gpu. Is there a possibility to do the same for jupyter notebook in windows.
You will actually need to use tensorflow-gpu to run your jupyter notebook on a gpu.
The best way to achieve this would be
Install Anaconda on your system
Download cuDNN & Cuda Toolkit 11.3 .
Add cuDNN and Cuda Toolkit to your PATH.
Create an environment in Anaconda
pip install tensorflow-gpu
pip install [jupyter-notebook/jupyterlab]
Import tensorflow-gpu in your notebook
Enjoy. You can now run your notebook on your GPU
Open Anaconda promote and Write
Now it's time to test if our code Run on GPU or CPU
Conda activate tf_GPU --- (Activating the env)
Jupyter notebook ----(Open notebook from the tf_GPU env)
if this Code gives you 1 this means you are runing on GPU
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
You can also use this code to make sure you run on GPU
tf.debugging.set_log_device_placement(True)
# Create some tensors
a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
c = tf.matmul(a, b)
print(c)
Geting output like this means you using CPU not GPU
Executing op _EagerConst in device /job:localhost/replica:0/task:0/device:CPU:0
Executing op _EagerConst in device /job:localhost/replica:0/task:0/device:CPU:0
Executing op MatMul in device /job:localhost/replica:0/task:0/device:CPU:0
tf.Tensor(
[[22. 28.]
[49. 64.]], shape=(2, 2), dtype=float32)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.