How to get cuda to load when running pytorch?

Viewed 133

I had an old conda virtual environment with pytorch and cudatoolkit 10.1. I was able to run the code and I would always get the following message at the beginning:

I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1

However, I created a new virtual environment with cudatoolkit 11.0, but now this message does not run at the beginning of the code (nor do I get an error message saying it failed to find the file), and the code crashes eventually when it tries to use the gpu. How do I make sure that it loads GPU support correctly?

1 Answers

In Tensorflow, to make sure that code is running on GPU properly or not, Run this sample code,

import tensorflow as tf
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)

#Output : It loads the GPU support
Executing op MatMul in device /job:localhost/replica:0/task:0/device:GPU:0
tf.Tensor(
[[22. 28.]
 [49. 64.]], shape=(2, 2), dtype=float32)
Related