Git Product home page Git Product logo

Comments (3)

malfet avatar malfet commented on June 4, 2024

Hmm, can you run any cuda program inside your container? Judging by the error it's very likely that GPU access from your container is misconfigured

from pytorch.

Wait845 avatar Wait845 commented on June 4, 2024

Thank you for your response. Here are my details:

> nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Feb__7_19:32:13_PST_2023
Cuda compilation tools, release 12.1, V12.1.66
Build cuda_12.1.r12.1/compiler.32415258_0

Here’s a simple CUDA test script (test.cu):

#test.cu
#include <stdio.h>

__global__ void add(int *a, int *b, int *c) {
    c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
}

int main() {
    int a[5] = {1, 2, 3, 4, 5};
    int b[5] = {10, 20, 30, 40, 50};
    int c[5] = {0};

    int *d_a, *d_b, *d_c;
    int size = sizeof(int) * 5;

    cudaMalloc((void **)&d_a, size);
    cudaMalloc((void **)&d_b, size);
    cudaMalloc((void **)&d_c, size);

    cudaMemcpy(d_a, a, size, cudaMemcpyHostToDevice);
    cudaMemcpy(d_b, b, size, cudaMemcpyHostToDevice);

    add<<<5,1>>>(d_a, d_b, d_c);

    cudaMemcpy(c, d_c, size, cudaMemcpyDeviceToHost);

    printf("η»“ζžœοΌš");
    for (int i = 0; i < 5; i++)
        printf("%d ", c[i]);
    printf("\n");

    cudaFree(d_a);
    cudaFree(d_b);
    cudaFree(d_c);

    return 0;
}

When I compiled and ran it:

> nvcc test.cu -o test
> ./test 
η»“ζžœοΌš0 0 0 0 0 

After many attempts, I found a solution: setting an environment variable before calling torch.cuda.is_available():

os.environ['CUDA_VISIBLE_DEVICES'] = "0"

I suspect this is because I moved the VM location from a host Windows system and reassigned the GPU to the VM. This resulted in two PCI devices showing up, but only one working:

lspci -v
63b6:00:00.0 3D controller: Microsoft Corporation Device 008e
	Physical Slot: 3509819646
	Flags: bus master, fast devsel, latency 0, NUMA node 0
	Capabilities: <access denied>
	Kernel driver in use: dxgkrnl
	Kernel modules: dxgkrnl

b330:00:00.0 3D controller: Microsoft Corporation Device 008e
	Physical Slot: 3646467553
	Flags: bus master, fast devsel, latency 0, NUMA node 0
	Capabilities: <access denied>
	Kernel driver in use: dxgkrnl
	Kernel modules: dxgkrnl

from pytorch.

jbschlosser avatar jbschlosser commented on June 4, 2024

As this seems to be an environment issue, I encourage you to post on the PyTorch forums if additional assistance is needed, as you're more likely to receive help there. Note that the issues here are reserved for bugs within PyTorch itself. Closing for now but feel free to reopen if forum discussion points to a PyTorch bug.

from pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.