win11+4060安装cuda,cuda toolkit,cudnn
目录
一、查看驱动版本
二、安装cuda toolkit
三、安装CUDNN
四、配置环境变量
一、查看驱动版本
首先搞清楚cuda驱动,cuda toolkit,cudnn是什么东西,有什么关系!
一般电脑的独显能正常使用,0说明已经安装好了显卡驱动,这是可以在命令窗口查看驱动版本信息,并通过版本信息,得到能安装的cuda toolkit的版本
C:\Users\fuhang>nvidia-smi
Wed Oct 8 17:14:01 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 566.24 Driver Version: 566.24 CUDA Version: 12.7 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Driver-Model | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 4060 ... WDDM | 00000000:01:00.0 Off | N/A |
| N/A 43C P0 11W / 80W | 0MiB / 8188MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------++-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+
二、安装cuda toolkit
CUDA 12.7说明支持的cuda toolkit的最高版本,参考这个信息选择安装cuda toolkit的版本,安装好以后查看版本信息如下
C:\Users\fuhang>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Oct_30_01:18:48_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.85
Build cuda_12.6.r12.6/compiler.35059454_0
Cuda compilation tools, release 12.6, V12.6.85指的是cuda toolkit的版本
三、安装CUDNN
下载地址:CUDNN
CUDNN的版本信息也指明了适配哪种CUDA版本,按照版本下载即可
解压下载文件
① 把cuDNN的bin目录下的文件复制到CUDA安装目录 bin目录下:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\bin
② 把cuDNN的include下的所有文件,复制到CUDA安装目录的include下:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\include
③ 把cuDNN的lib\x64下的所有文件,拷贝到CUDA安装目录的lib\x64下:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\lib\x64
四、配置环境变量
需要手动添加以下环境变量到系统变量里:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\libnvvp
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\extras\CUPTI\lib64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\include
在cmd下执行如下2条命令,可查看CUDA驱动版本、CUDA Runtime版本以及GPU显卡的型号等信息
cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\extras\demo_suite
.\deviceQuery.exe
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\extras\demo_suite>.\deviceQuery.exe
.\deviceQuery.exe Starting...CUDA Device Query (Runtime API) version (CUDART static linking)Detected 1 CUDA Capable device(s)Device 0: "NVIDIA GeForce RTX 4060 Laptop GPU"CUDA Driver Version / Runtime Version 12.7 / 12.6CUDA Capability Major/Minor version number: 8.9Total amount of global memory: 8188 MBytes (8585216000 bytes)
MapSMtoCores for SM 8.9 is undefined. Default to use 128 Cores/SM
MapSMtoCores for SM 8.9 is undefined. Default to use 128 Cores/SM(24) Multiprocessors, (128) CUDA Cores/MP: 3072 CUDA CoresGPU Max Clock rate: 1890 MHz (1.89 GHz)Memory Clock rate: 8001 MhzMemory Bus Width: 128-bitL2 Cache Size: 33554432 bytesMaximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layersMaximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layersTotal amount of constant memory: zu bytesTotal amount of shared memory per block: zu bytesTotal number of registers available per block: 65536Warp size: 32Maximum number of threads per multiprocessor: 1536Maximum number of threads per block: 1024Max dimension size of a thread block (x,y,z): (1024, 1024, 64)Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)Maximum memory pitch: zu bytesTexture alignment: zu bytesConcurrent copy and kernel execution: Yes with 1 copy engine(s)Run time limit on kernels: YesIntegrated GPU sharing Host Memory: NoSupport host page-locked memory mapping: YesAlignment requirement for Surfaces: YesDevice has ECC support: DisabledCUDA Device Driver Mode (TCC or WDDM): WDDM (Windows Display Driver Model)Device supports Unified Addressing (UVA): YesDevice supports Compute Preemption: YesSupports Cooperative Kernel Launch: YesSupports MultiDevice Co-op Kernel Launch: NoDevice PCI Domain ID / Bus ID / location ID: 0 / 1 / 0Compute Mode:< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 12.7, CUDA Runtime Version = 12.6, NumDevs = 1, Device0 = NVIDIA GeForce RTX 4060 Laptop GPU
Result = PASSC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\extras\demo_suite>
CUDA Driver = CUDART,
CUDA Driver Version = 12.7,
CUDA Runtime Version = 12.6,
NumDevs = 1,
Device0 = NVIDIA GeForce RTX 4060 Laptop GPU
Result = PASS
说明安装成功