# Nivdia

## 安裝NVIDIA CUDA <a href="#an-zhuang-nvidiacuda" id="an-zhuang-nvidiacuda"></a>

CUDA是NVIDIA GPU用於平行運算的程式架構，我們可以利用CUDA進行深度學習的建模，由於目前大多GPU的運算速度是高於CPU，所以利用GPU加速深度學習模型運算是目前最主流的方法。因此，確認過電腦的GPU是支援CUDA運算架構之後，我們就開始來安裝CUDA。

## 搭配組合(持續更新) <a href="#da-pei-zu-he-chi-xu-geng-xin" id="da-pei-zu-he-chi-xu-geng-xin"></a>

| **TensorFlow (gpu)** | **CUDA** | **cuDNN** | **更新時間**        |
| -------------------- | -------- | --------- | --------------- |
| **(最新) 1.7**         | **9.1**  | **7.1.2** | **2018.4 (最新)** |
| 1.5                  | 9.0      | 7(.0.4/5) | 2018.2          |
| 1.3                  | 8.0      | 6.0       | 2017.11         |
| 1.0                  | 8.0      | 5.1       | 2017.8          |

**請下載目前CUDA最新9.1版（2018.4 更新）**，並請確認是否支援以下作業系統：

**Table 1. Windows Operating System Support in CUDA 9.1**

|                        | Native x86\_64 | Cross (x86\_32 on x86\_64) |
| ---------------------- | -------------- | -------------------------- |
| Windows 10             | YES            | YES                        |
| Windows 8.1            | YES            | YES                        |
| Windows 7              | YES            | YES                        |
| Windows Server 2016    | YES            | NO                         |
| Windows Server 2012 R2 | YES            | NO                         |

安裝CUDA之前，必須先安裝Windows Visual Studio，請確認安裝的版本。

**Table 2. Windows Compiler Support in CUDA 9.1**

| Compiler                       | IDE                          | Native x86\_64 | Cross (x86\_32 on x86\_64) |
| ------------------------------ | ---------------------------- | -------------- | -------------------------- |
| Visual C++ 15.0                | Visual Studio 2017           | YES            | NO                         |
| Visual C++ 14.0                | Visual Studio 2015           | YES            | NO                         |
|                                | Visual Studio Community 2015 | YES            | NO                         |
| Visual C++ 12.0                | Visual Studio 2013           | YES            | YES                        |
| Visual C++ 11.0                | Visual Studio 2012           | YES            | YES                        |
| Visual C++ 10.0 **DEPRECATED** | Visual Studio 2010           | YES            | YES                        |

資料來源：<http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html#axzz4oJ4It0ks>

#### 示範作業系統：Windows 10 64-bit <a href="#shi-fan-zuo-ye-xi-tong-windows1064bit" id="shi-fan-zuo-ye-xi-tong-windows1064bit"></a>

1.安裝 [Visual C++ Redistributable for Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145)

2.安裝 [CUDA 9.1](https://developer.nvidia.com/cuda-downloads)

選擇對應的作業系統環境，安裝CUDA和Patch。(**安裝非最新版CUDA請至**[**https://developer.nvidia.com/cuda-toolkit-archive**](https://www.gitbook.com/book/pydatascience/pythondeeplearning/edit) **下載**)![](https://pydatascience.gitbooks.io/pythondeeplearning/content/assets/%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%20\(13\).png)![](https://pydatascience.gitbooks.io/pythondeeplearning/content/assets/%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%20\(14\).png)

**補充：舊版CUDA須從歷史安裝頁面下載**

nvidia-smi -l 1

{% embed url="<https://developer.nvidia.com/cuda-toolkit-archive>" %}

3.安裝 [cuDNN](https://developer.nvidia.com/rdp/cudnn-download)

\*\*<https://developer.nvidia.com/rdp/cudnn-archive**&#x20>;

## Check GPU Usage (CUDA)

### Linux

continually give you the gpu usage info, with in refresh interval of 1 second&#x20;

```bash
nvidia-smi -l 1
```

{% embed url="<https://github.com/wookayin/gpustat>" %}
