Importing TensorFlow stops python program from run

2019-07-22 12:31发布

I have Python Tools setup in Visual Studios with CPython installed.

In Visual Studios, if i run the following code:

print("hello");
import numpy;
print("hello");

The program runs fine, prints two 'hello', and exits normally.

However, if I run the following code:

print("hello");
import tensorflow;
print("hello");

The program hangs, prints one 'hello', and refuses to continue.

All packages should be correctly installed - using the TensorFlow in the Python interactive window prints the correct output and works perfectly.

Why does the program hang in the second scenario?

1条回答
一纸荒年 Trace。
2楼-- · 2019-07-22 13:12

Once you import tensorflow it automatically tries to load cuda, it prints something like this:

I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally

So I think what is happening is that you don't have cuda installed correctly and it is failing because of it. You can try to install the CPU version which doesn't use the GPU and doesn't load those libraries.

查看更多
登录 后发表回答