Score:0

Can't activate Nvidia GPU on Ubuntu 22.04 (WSL2)

ph flag

Problem definition

I have been trying to use my mobile Quadro T1000 with cuda in pytorch, but pytorch use CPU whatever I do. I installed pytorch, GPU drivers and CUDA Toolkit.

If I run command I get nothing

lspci | grep -i nvidia

Pytorch info:
torch.__version__: 1.13.0+cu117
torch.version.cuda: 11.7
torch.cuda.current_device(): 0
torch.cuda.is_available(): True

Windows 10 Pro 21H2

Extra info:

  1. lspci

    3a66:00:00.0 3D controller: Microsoft Corporation Basic Render Driver
    4498:00:00.0 3D controller: Microsoft Corporation Basic Render Driver

  2. nvcc -V

    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2022 NVIDIA Corporation
    Built on Wed_Sep_21_10:33:58_PDT_2022
    Cuda compilation tools, release 11.8, V11.8.89
    Build cuda_11.8.r11.8/compiler.31833905_0

  3. nvidia-smi

https://i.stack.imgur.com/4p5UE.png

  1. dpkg -l | grep linux-modules-nvidia - nothing
  2. dpkg -l | grep nvidia-driver - nothing
  3. uname -a
    Linux CPR-5CD111 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  4. inxi -G

Graphics:
Device-1: Microsoft Basic Render Driver driver: dxgkrnl v: N/A
Device-2: Microsoft Basic Render Driver driver: dxgkrnl v: N/A
Display: server: No display server data found. Headless machine? tty: 145x14
Message: GL data unavailable in console. Try -G --display

  1. grep 10de /lib/udev/rules.d/* - nothing

  2. dmesg | grep nvidia - nothing

  3. dmesg | grep NV - nothing

    def train(res_model, criterion, optimizer, train_dataloader, test_dataloader, NUM_EPOCH=15):
      for epoch in tqdm(range(NUM_EPOCH)):
        model.train()
        train_loss = 0.
        train_size = 0
    
        train_pred = 0.
    
        for imgs, labels in train_dataloader:
            optimizer.zero_grad()
    
            imgs = imgs.cuda()
            labels = labels.cuda()
    
            y_pred = model(imgs)
    
            loss = criterion(y_pred, labels)
            loss.backward()
    
            train_loss += loss.item()
            train_size += y_pred.size(0)
            train_loss_log.append(loss.data / y_pred.size(0))
    
            train_pred += (y_pred.argmax(1) == labels).sum()
    
            optimizer.step()
    
NotTheDr01ds avatar
vn flag
Since the GPU itself isn't *directly* exposed to WSL2, the output of most of those commands looks completely expected to me. I'll try to explain more in an answer later (have to step away for a while and may not get back to it until tomorrow), but let's focus on your core problem -- *"but pytorch use CPU whatever I do."* Can you provide some sample code? Note also that installing GPU drivers and CUDA toolkit in Ubuntu is unnecessary -- All that should be required is a recent *Windows* NVIDIA driver -- WSL2 should do the rest of the virtualization/passthrough.
NotTheDr01ds avatar
vn flag
Also, can you provide your Windows version? 10 or 11? Which build -- GPU compute requires 21H2 or later. Thanks!
Terrance avatar
id flag
You might want to see: https://ubuntu.com/tutorials/enabling-gpu-acceleration-on-ubuntu-on-wsl2-with-the-nvidia-cuda-platform#1-overview
sergzemsk avatar
ph flag
@NotTheDr01ds Windows 10 Pro 21H2
sergzemsk avatar
ph flag
@NotTheDr01ds I removed some lines of code, it's just some part of code def train(res_model, criterion, optimizer, train_dataloader, test_dataloader, NUM_EPOCH=15): for epoch in tqdm(range(NUM_EPOCH)): model.train() train_loss = 0. train_size = 0 train_pred = 0 for imgs, labels in train_dataloader: optimizer.zero_grad() imgs = imgs.cuda() labels = labels.cuda() y_pred = model(imgs) loss = criterion(y_pred, labels) loss.backward()
sergzemsk avatar
ph flag
@Terrance I use instructions https://docs.nvidia.com/cuda/archive/11.7.1/wsl-user-guide/index.html and https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#pre-installation-actions
NotTheDr01ds avatar
vn flag
@sergzemsk Please edit the question to include any code (in Markdown code-blocks). It is, as you might have noticed, unreadable in a comment ;-).
sergzemsk avatar
ph flag
@NotTheDr01ds done
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.