AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1464271
Accepted
mLstudent33
mLstudent33
Asked: 2023-04-19 23:08:22 +0800 CST2023-04-19 23:08:22 +0800 CST 2023-04-19 23:08:22 +0800 CST

这是 WSL2 的默认 nvidia 驱动程序吗?

  • 772
noob@LAPTOP-DNCQ5AAC:/mnt/d/gatechFall2022/ihpc/lab1fa22/part2$ nvidia-smi
Thu Apr 20 00:04:03 2023       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.100      Driver Version: 528.76       CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   41C    P8     2W /  50W |      0MiB /  4096MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A       227      G   /Xwayland                       N/A      |
+-----------------------------------------------------------------------------+

它说的是,“小心不要安装另一个覆盖默认设置的”在这里https://docs.nvidia.com/cuda/wsl-user-guide/index.html

在我开始尝试在我的 Windows 11 机器上再次安装 cuda 之前,这是我的默认设置吗?有没有人有关于如何在 WSL2 上安装 cuda 的好答案的链接?
我可能不得不搜索我自己的问题,但请记住它从未真正按预期工作,我不得不使用 Windows 系统。

我想用 Cuda 执行的任务如下:

/*
My Chatgpt prompt:
"implement helman-jaja list rank where the function signature is "void cudaListRank (long head, const long* next, long* rank, size_t n)" where the first parameter head is the index into array representation of a linked list and points to its head,  the second parameter next is a "next array" that gives the index of the next node in the array representation of a linked list, the third parameter rank is an array holding the rank of each node in the array representation of a linked list and the fourth parameter n is the length of the array representation of a linked list."
The code written by ChatGPT below:
*/

#include <unistd.h>
#include "listutils.h"                        
#include <math.h>
#include <cuda.h>
#include <curand.h>

void cudaListRank(long head, const long* next, long* rank, size_t n) {
    // Allocate memory for the linked list nodes and next array on the device
    long* devNext;
    long* devRank;
    cudaMalloc((void**)&devNext, n * sizeof(long));
    cudaMalloc((void**)&devRank, n * sizeof(long));

    // Copy the input linked list next array from host to device
    cudaMemcpy(devNext, next, n * sizeof(long), cudaMemcpyHostToDevice);

    // Initialize rank array on the device to all 1's
    cudaMemset(devRank, 1, n * sizeof(long));

    // Launch a CUDA kernel that performs the scan phase of Helman-Jaja list rank
    int block_size = 256;
    int num_blocks = (n + block_size - 1) / block_size;
    helmanJajaScan<<<num_blocks, block_size>>>(head, devNext, devRank);

    // Launch another CUDA kernel that performs the increment phase of Helman-Jaja list rank
    helmanJajaIncrement<<<num_blocks, block_size>>>(devNext, devRank);

    // Copy the updated rank array from device to host
    cudaMemcpy(rank, devRank, n * sizeof(long), cudaMemcpyDeviceToHost);

    // Free the allocated memory on the device
    cudaFree(devNext);
    cudaFree(devRank);
}


//more kernels
/*
Note that in helmanJajaScan, we're traversing the linked list one node at a time and accumulating the ranks. In helmanJajaIncrement, we're traversing the list in reverse order and adding the accumulated ranks to each node's rank.

Also note that cudaMemcpyHostToDevice and cudaMemcpyDeviceToHost are used for transferring data between host and device memory. Finally, cudaMalloc and cudaFree are used to allocate and free device memory respectively.
*/
__global__ void helmanJajaScan(long head, const long* next, long* rank) {
    int tid = threadIdx.x + blockIdx.x * blockDim.x;

    // Traverse the linked list
    while (head != -1) {
        long curr = head;
        for (int i = 0; i < tid && curr != -1; i++) {
            curr = next[curr];
        }

        if (curr == -1 || next[curr] == -1) break;

        rank[next[curr]] += rank[curr];

        __syncthreads();
    }
}

__global__ void helmanJajaIncrement(const long* next, long* rank) {
    int tid = threadIdx.x + blockIdx.x * blockDim.x;

    // Traverse the linked list
    while (tid < gridDim.x * blockDim.x) {
        long curr = tid;
        for (int i = 0; i < blockDim.x && curr != -1; i++) {
            curr = next[curr];
        }

        if (curr == -1) break;

        rank[curr] += rank[next[curr]];

        tid += gridDim.x * blockDim.x;
    }
}


现在,当我尝试使用 Make 文件进行编译时,我得到了

noob@LAPTOP-DNCQ5AAC:/mnt/d/gatechFall2022/ihpc/lab1fa22/part2$ make correctness IMPL=hj
nvcc -Iutils -O0 -g -std=c++11 -o student/cuda_hj.o -c student/cuda_hj.cu
make: nvcc: Not a directory
make: *** [Makefile:8: student/cuda_hj.o] Error 127

此外,我在 VSCode 中看到与 cuda 相关的导入语句的红色波浪下划线,但不确定这是否表明我的 WSL-remote-VSCode 和默认 Cuda 是否运行良好。

我还从 Nvidia 下载并尝试安装两个不同的 cuda 包(WSL 版本)进行安装,但都没有完成工作(我从下载页面复制并粘贴了每个终端指令):

cuda_12.1.0_530.30.02_linux.run
cuda-repo-wsl-ubuntu-12-1-local_12.1.0-1_amd64.deb
drivers
  • 1 1 个回答
  • 41 Views

1 个回答

  • Voted
  1. Best Answer
    NotTheDr01ds
    2023-04-21T08:51:05+08:002023-04-21T08:51:05+08:00

    首先,考虑您的项目是否真的需要完整的 CUDA 工具包。许多 CUDA 任务可以仅使用注入到每个 WSL 实例中的提供的 WSL CUDA 库来完成。

    例如,如果没有安装 CUDA 工具包,请查看:

    ls /usr/lib/wsl/lib
    

    你会看到,除其他外,libcuda.so那里。这个注入的库被挂接到Windows NVIDIA 驱动程序中。出于这个原因,CUDA 工具包安装页面会警告您不要在 WSL 中安装Linux驱动程序——这样做会破坏 WSL/CUDA 集成。

    您将在 WSL文档页面上找到有关如何使用现有 CUDA(和/或 DirectML)集成的Microsoft CUDA 说明:

    • 火炬
    • 张量流
    • 或者使用 NVIDIA Docker 容器

    我已经亲自测试了 PyTorch 和 TensorFlow 的集成,但目前还没有测试 Docker 容器。

    同样,这是 WSL 的“开箱即用”功能,只要您有受支持的 Windows 版本(目前大多数最新的受支持版本)和最新的 NVIDIA Windows 驱动程序。您无需安装 CUDA 工具包即可使用这些方面。

    这是 WSL2 的默认 nvidia 驱动程序吗?

    好吧,非常接近。据我所知,是的,它是附加到 Windows 驱动程序的 WSL 驱动程序。否则,我不相信它会看到物理 GPU。

    不过,它有点过时了——新的 Windows 驱动程序于 11 月 18 日发布。在我的 Ubuntu/WSL 中安装 CUDA 工具包后,我收到一条消息,提示我需要一个 >= 530 的驱动程序来支持最新的工具包。

    因此,如果您确实想要安装完整的 CUDA 工具包,例如,使用 NVIDIA 编译器 (NVCC) 构建本机应用程序,您将需要更新 Windows Game Ready 驱动程序(当然还要重新启动 Windows)。

    然后,您应该按照所链接网站上的说明进行操作。确保下载 CUDA 工具包的 WSL 版本,因为 Ubuntu 的所有“标准”工具包都包含Linux驱动程序。

    据报道,该版本中可能找不到 NVIDIA 编译器.deb,但也有可能它只是不包含与该.run版本相同的指令(将其添加到路径中)。最后,我下载了这个.run版本。

    您还需要:

    sudo apt install build-essential
    

    然后你可以:

    wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_530.30.02_linux.run
    sudo sh cuda_12.1.1_530.30.02_linux.run
    

    不过,请使用实际下载页面上的说明,以确保您获得最新版本(而不是撰写本文时的最新版本)。

    然后,按照安装程序提供的说明添加必要的PATH项目LIB_PATH。

    请注意,虽然我已经安装了 Toolkit,而且我相信成功了,但我没有测试项目来尝试它。正如评论中提到的,该工具包有很多可能的用途,并且在没有关于您的预期用例的详细信息的情况下,我无法为您确认。

    • 1

相关问题

  • Ubuntu 中的科胜讯调制解调器

  • 如何解决联想笔记本电脑上恢复/电源问题时禁用的蓝牙?

  • 如何为 LG X130 上网本安装 relink 无线驱动程序

  • 类似于 Eyefinity 的东西?

  • 在哪里可以找到 Brother HL-2170W 64 位打印机驱动程序?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve