Skip to content

CUDA not available in TorchSharp (.NET Interactive) but available in Console app (WSL - Ubuntu 24.04 + .NET 9.0.8) #1491

@phil-kotze

Description

@phil-kotze

Describe the bug
CUDA not available in TorchSharp (.NET Interactive) but available in Console app (Ubuntu 24.04 + .NET 9.0.8)

To Reproduce
Run the same code calling torch.cuda.is_available() in Polyglot Notebooks vs .NET Console App

----- Polyglot Notebooks ------

#r "nuget: TorchSharp-cuda-linux"
using System.Runtime.InteropServices;
using TorchSharp;

  Console.WriteLine($"Running on: {RuntimeInformation.FrameworkDescription}");
  
 if (torch.cuda.is_available())
    {
        Console.WriteLine("CUDA is available.");
    }
    else
    {
        Console.WriteLine("CUDA is not available. No GPU devices found.");
    }

Output:

Running on: .NET 9.0.8
CUDA is not available. No GPU devices found.

----- Console App------

dotnet add package TorchSharp-cuda-linux


using TorchSharp;
using System.Runtime.InteropServices;

public class Program
{

    public static void Main(string[] args)
    {

        Console.WriteLine($"Running on: {RuntimeInformation.FrameworkDescription}");

        if (torch.cuda.is_available())
        {
            Console.WriteLine("CUDA is available.");
        }
        else
        {
            Console.WriteLine("CUDA is not available. No GPU devices found.");
        }

    }
}

dotnet run

Output:

Running on: .NET 9.0.8
CUDA is available.


**Expected behavior**
CUDA to be available in .NET Interactive

**Please complete the following information:**
 - OS: WSL - Ubuntu 24.04
 - Package Type torchsharp-cuda-linux
 - Version [e.g. 0.105.1

]

**Additional context**
<img width="826" height="1331" alt="Image" src="https://github.com/user-attachments/assets/d2e70e90-da6c-405e-937f-cf2295387b32" />
<img width="829" height="672" alt="Image" src="https://github.com/user-attachments/assets/02131ff9-35d5-4c4b-b73e-daa2427ae6e0" />

---

Thanks for your contribution!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions