Skip to content

Commit

Permalink
feat: WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhanhan committed Dec 11, 2024
1 parent c0e096f commit 4480315
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions _posts/工作日志/Linux/2024-12-11-wsl-cuda.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
layout: post
category: [工作日志, Linux]
tags: [Linux, CUDA]
title: Window子系统中安装Cuda
---



## 安装
一旦系统上安装了 Windows NVIDIA GPU 驱动程序,CUDA 就可以在 WSL 2 中使用。安装在 Windows 主机上的 CUDA 驱动程序将在 WSL 2 中存根为libcuda.so ,因此用户不得在 WSL 中安装任何 NVIDIA GPU Linux 驱动程序2 .这里必须非常小心,因为默认的 CUDA Toolkit 附带了一个驱动程序,并且很容易用默认安装覆盖 WSL 2 NVIDIA 驱动程序。我们建议开发人员使用可从 CUDA工具包下载页面获取的单独的 WSL 2 (Ubuntu) CUDA 工具包,以避免这种覆盖。此 WSL-Ubuntu CUDA 工具包安装程序不会覆盖已映射到 WSL 2 环境中的 NVIDIA 驱动程序。要了解如何编译 CUDA 应用程序,请阅读适用于 Linux 的 CUDA 文档。

1. 首先,删除旧的 GPG 密钥:

```bash
sudo apt-key del 7fa2af8
```

2. 使用 WSL-Ubuntu 软件包安装 Linux x86 CUDA 工具包
打开地址: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local
可自行下载。

快捷命令:
```bash
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda-repo-wsl-ubuntu-12-6-local_12.6.3-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-12-6-local_12.6.3-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-6
```




## 参考:
- https://learn.microsoft.com/zh-cn/windows/ai/directml/gpu-cuda-in-wsl
- https://docs.nvidia.com/cuda/wsl-user-guide/index.html#getting-started-with-cuda-on-wsl-2

0 comments on commit 4480315

Please sign in to comment.