問題描述
安裝了anaconda的電腦,新建了一個名叫deeplearning的環境,在該環境下已經成功安裝了tensorflow。
于是在終端打開python并執行代碼
import tensorflow as tf
print(1)
除了提示
2024-02-27 21:50:00.801427: I external/local_tsl/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
2024-02-27 21:50:00.838675: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-02-27 21:50:00.838709: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-02-27 21:50:00.839681: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-02-27 21:50:00.845214: I external/local_tsl/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
2024-02-27 21:50:00.845380: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-02-27 21:50:01.529134: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
1
錯誤提示是代表沒有安裝TensorRT,暫時忽略,可以看出已經打印了1,已經安裝成功。
但是運行juypter-notebook后,會提示
ModuleNotFoundError: No module named 'tensorflow'
原因
在新建環境下,沒有安裝juypter-notebook,導致運行的juypter-notebook實際上仍然是base環境下的,因此失敗
解決
conda activate deeplearning
conda install nb_conda
這樣就在deeplearning安裝了juypter-notebook了。
問題解決。