Developing issues
I just have some questions about developing on TorchSharp:
- I use Visual Studio 2022, but it doesn't give me IntelliSens support in the TorchSharp library. I'm not sure why, or how to resolve that.
- I can run the tests using
dotnet test, but that runs all the tests, while it would be nice to just run the new tests I create. Is there some configuration I am missing to make the tests appear in the test explorer, for example?
That is odd. I also use VS 2022, and I'm seeing both Intellisense and the unit tests appear in the test explorer. You sometimes need to do a 'run all' in the text explorer in order for the tests to appear, I have found.
I managed to get the above working, but now when I want to run tests, I get the following error: Severity Code Description Project File Line Suppression State Details Error CS0006 Metadata file 'C:...\TorchSharp\bin\AnyCPU.Debug\TorchSharp\netstandard2.0\TorchSharp.dll' could not be found TorchAudio (net6.0) C:...\TorchSharp\src\TorchAudio\CSC 1 Active There's in total 7 such errors (each at a slightly different path for the different projects and builds)
Any ideas?
What packages are you using? Start with TorchSharp-cpu. What version of .NET are you using?
Not sure what you mean with packages. How can I ensure only TorchSharp-cpu is being built?
As for the version of .NET:
dotnet --list-sdks
8.0.200 [C:\Program Files\dotnet\sdk]
dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
I do find that when I try to build the TorchSharp project separately, it complains about cmake not existing:
Build started at 16:02...
1>------ Build started: Project: TorchSharp (src\TorchSharp), Configuration: Debug Any CPU ------
1>Using VersionSuffix =
1>Using Version = 0.101.5
1>Using VersionSuffix =
1>Using Version = 0.101.5
1>C:\...\TorchSharp\src\Native\build.cmd Debug x64 --libtorchpath C:\...\TorchSharp\bin/obj/AnyCPU.Debug\libtorch-cpu\libtorch-win-shared-with-deps-debug-2.1.0cpu\libtorch\share\cmake\Torch
1>The system cannot find the path specified.
1>Commencing native build of dotnet/machinelearning
1>
1>Calling "C:\...\TorchSharp\src\Native\\gen-buildsys-win.bat" "C:\...\TorchSharp\src\Native\" "17 2022" x64
1>CMake is a pre-requisite to build this repository but it was not found on the path. Please install CMake from https://www.cmake.org/download/ and ensure it is on your path.
1>Failed to generate native component build project!
1>C:\...\TorchSharp\src\Native\build.proj(53,5): error MSB3073: The command ""C:\...\TorchSharp\src\Native\build.cmd" Debug x64 --libtorchpath C:\...\TorchSharp\bin/obj/AnyCPU.Debug\libtorch-cpu\libtorch-win-shared-with-deps-debug-2.1.0cpu\libtorch\share\cmake\Torch" exited with code 1.
1>Done building project "build.proj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 16:02 and took 03,005 seconds ==========
However, I have the C++ CMake tools for Windows installed. Adding C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin to my PATH also didn't help.
I'm sorry. I completely missed that you were doing from-source builds. Have you checked out the DEVGUIDE.md file?
When building, always run from a VS 'x64 Native Tools...' window -- that sets up the right environment. Start VS from that window, with devenv TorchSharp.sln. Here's what I see:
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.9.1
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
c:\Users\niklasg\source\repos\niklasgustafsson>where cmake
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
@NiklasGustafsson I am very sure this answer needs a more prominent way to be available to new users.
Haven't seen anything on this for a while. I'm going to assume the question has been addressed.