請參閱英文版的安裝,下方網址要點右上角切換至英文才有方法
https://www.tensorflow.org/install/pip
簡單而言現在Tensorflow 2.10版以上都無法在Windows上使用GPU,但好消息是可以連同CUDA一起安裝。
首先安裝WSL2,開啟Powershell(系統管理員)

然後一行指令安裝
wsl --install
安裝完後你要重新開機,重新開機完後會要你輸入帳密,之後你就可以按照英文官方安裝GPU版的Tensorflow。但為了以後開發方便我們繼續來安裝Anaconda
首先先去官網複製下載網址
https://www.anaconda.com/download#downloads

然後貼到WSL裡面,使用wget下載

下載完後執行,接下來引導式安裝

預設安裝位置是家目錄中的Anaconda3

如果下conda指令找不到就在bashrc裡面加上PATH
nano ~/.bashrc
或是直接下指令
export PATH="/home/[user]/anaconda3/bin/:$PATH"
然後呢 就可以啟用
conda init
source ~/.bashrc
指令啟用環境
conda activate
退出環境
conda deactivate
如果安裝2.16版使用GPU會出現錯誤,且找不到GPU
2024-03-09 16:22:45.531685: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-03-09 16:22:45.787261: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-03-09 16:22:46.518153: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-03-09 16:22:47.403086: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:984] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-09 16:22:47.474378: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2251] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
[]
解決方式是直接再安裝2.15就好了,會自動解除安裝新版
pip install tensorflow==2.15
補充指令
新增環境
conda create -n [環境名稱]
刪除環境
conda env remove --name [環境名稱]
預設開啟環境
conda config --set auto_activate_base True