Every times when Nvidia updates its drivers, the task with Tensorflow is more or least impacted.
Quote from TF's website:
TensorFlow 2.10 was the last TensorFlow release that supported GPU on native-Windows. Starting with TensorFlow 2.11, you will need to install TensorFlow in WSL2, or install tensorflow or tensorflow-cpu and, optionally, try the TensorFlow-DirectML-Plugin.
PyTorch works fine with CUDA. With some modifications on environment variables to use the toolkit 12.1, it is easy to setup for running PyTorch projects on Windows with GPU.
To attempt to run TF project on WSL2 with GPU, there comes an idea to create a C# project to run a WSL-python-script process on Windows.
- Create a C# WinForm project with Visual Studio.
- Set the project with x64 platform (replace with "Any CPU")!
(Otherwise, the running process will be in 32-bit, on which, WSL is not installed.)
The code looks like this (Please refer to the original code):
If you create a C# console project, you should replace "textBoxLog.AppendText" with "Console.Write".
using (var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = @"wsl.exe",
Arguments = @"-l -o",
// some other examples:
// Arguments = @"-l -v",
// Arguments = @"--list",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true,
StandardOutputEncoding = Encoding.Unicode // Unicode is OK
}
})
{
proc.Start();
proc.WaitForExit();
var c = proc.StandardOutput.ReadToEnd();
// here, the textBoxLog, will receive the standard output.
// Create this textBoxLog on your WinForm UI.
textBoxLog.AppendText($"{c}");
textBoxLog.AppendText("Done");
textBoxLog.AppendText("");
}
Ok, there is no python script in the above example. But the most important thing is the setting with x64 to run wsl.
Comments