## 安裝和設定: GPU相關套件 0. 安裝[NVIDIA Driver](https://www.nvidia.com/Download/index.aspx) (此步驟可能可略過,因為教室的機器應該都有安裝好NVIDIA驅動程式) 2. 設定NVSMI (看NVIDIA DRIVER有沒有裝好)。 1. 將```C:\Program Files\NVIDIA Corporation\NVSMI```加入System ```PATH```。 2. 加入後, 開啟終端機 (如GIT BASH或Windows命令提示字元), 然後輸入```nvidia-smi.exe```, 按Enter, 即可顯示出GPU使用率等資訊。 3. 安裝[CUDA v11.3.10](https://developer.nvidia.com/cuda-11.3.0-download-archive)。[[下載連結]](https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda_11.3.0_465.89_win10.exe) 4. 安裝[cuDNN v 8.4.0 (需與CUDA v11.3.10相容)](https://developer.nvidia.com/cudnn)。[[下載連結]](https://www.dropbox.com/s/vg4yp1cf5hvf2p3/cudnn-windows-x86_64-8.4.0.27_cuda11.6-archive.zip?dl=1) 將解壓縮後的cuDNN資料夾內的檔案, 逐一複製到```C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3```。 4. 執行以下指令,確定nvcc有被安裝 (用以間接檢查看CUDA有沒有裝起來) ```nvcc -V``` 5. 安裝PyTorch (要選擇支持CUDA v11.3的Python Wheel) https://pytorch.org/get-started/locally/ 安裝好後, 執行python, 然後載入PyTorch並且嘗試看能否印出PyTorch版本: ```python import torch print(torch.__version__) # 1.10.0 ``` 6. 安裝TensorFlow: https://www.tensorflow.org/install/gpu?hl=zh-tw 1. 拿到TensorFlow的輪子 (`tensorflow-2.7.0-cp39-cp39-win_amd64.whl`)後, 執行```pip install tensorflow-2.7.0-cp39-cp39-win_amd64.whl```即可完成安裝. 2. 檢查TensorFlow是否可把張量丟到GPU ```python In [1]: import tensorflow as tf In [2]: tf.__version__ Out[2]: '2.7.0' In [3]: import numpy as np In [4]: tmp = np.random.normal(0, 1, (3, 3)) In [5]: tmp Out[5]: array([[-0.58497332, 0.91560168, 0.35745953], [ 0.36502097, 0.81025645, 1.17180727], [ 0.50818861, -1.05783736, -1.82408266]]) In [6]: tmp = tmp.astype(np.float32) In [7]: tmp.dtype Out[7]: dtype('float32') In [8]: tmp = tf.constant(tmp) 2021-12-28 20:23:09.054421: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-12-28 20:23:09.522473: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 2774 MB memory: -> device: 0, name: NVIDIA GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1 In [9]: tmp.device Out[9]: '/job:localhost/replica:0/task:0/device:GPU:0' ``` ## 安裝其他非GPU相關套件 請安裝Anaconda後,加裝如下套件: * 基本套件 ```bash pip install pandas matplotlib seaborn numpy scipy ``` * 機器學習套件 ```bash pip install sklearn ``` * 其它套件 ```bash pip install pillow graphviz pip install mlxtend pip install numexpr conda install -y shapely pip install imgaug opencv-python==4.4.0.46 pip install jupyterlab ```