build native pack of Torchsharp and libtorch for arm64 ubuntu
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Quiet
- Domain
- build-system, devtools, machine-learning
Research direction
Start with src/Native/build.proj and src/Native/build.sh, then trace the failing --libtorchpath shown in the build error. Compare that path with the ARM64 installation under src/Native/NativeDependencies/arm64-linux/libtorch and the generated /pytorch/build/install directory. Done means the native build uses the locally built LibTorch without downloading the x86 package, and dotnet build and dotnet pack complete successfully.
Written by the indexing model from the issue text.
Description
How to build native pack of Torchsharp and libtorch on arm64 ubuntu 24.04?
sudo apt update
sudo apt install -y git cmake build-essential python3 python3-pip
libopenblas-dev libomp-dev python3.12-dev python3-venv
wget https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --channel 8.0
export PATH=$PATH:$HOME/.dotnet
git clone --recursive https://github.com/pytorch/pytorch.git
cd pytorch
sudo apt install python3-venv python3-full
python3 -m venv ~/pytorch-env
source ~/pytorch-env/bin/activate
=== 1. Prepare environment ===
sudo apt update
pip install --upgrade pip setuptools wheel
pip install typing_extensions numpy pyyaml
pip install -r requirements.txt
=== 2. Clone PyTorch and install deps ===
git clone --recursive https://github.com/pytorch/pytorch.git
cd pytorch
git checkout 2.7.1
pip install -r requirements.txt
Clean any old build
rm -rf build
=== 3. Build LibTorch for ARM64 ===
tmux new -s pytorch-build
python3 setup.py build | tee build.log
#if ssh closed use this for keept it
- If SSH disconnects, reconnect and run
tmux attach -t pytorch-build.
#for detach from tmux
Ctrl + b, then d
#Check logs if needed
tail -f ~/pytorch/build.log
Generate LibTorch dir include bin,lib,share,...
cd /pytorch/build
cmake --install . --prefix ./install
back to root
cd /
=== 4. Clone TorchSharp and integrate LibTorch ===
git clone https://github.com/dotnet/TorchSharp.git
cd TorchSharp
Copy native libs into TorchSharp NativeDependencies
mkdir -p src/NativeDependencies/arm64-linux/libtorch
cp -r /pytorch/build/install/* /TorchSharp/src/Native/NativeDependencies/arm64-linux/libtorch
cd /TorchSharp/src/Native
cmake -DCMAKE_PREFIX_PATH=/TorchSharp/src/Native/NativeDependencies/arm64-linux/libtorch -DCMAKE_BUILD_TYPE=Release
=== 5. link TorchSharp to natively built libtorch ===
how to do that?
how to do that?
I'm stock here!!!!!!!!!
=== 6. Build and pack TorchSharp NuGet ===
dotnet build -c Release
dotnet pack -c Release
I'm stock at step 5 , when going to do step 6, it download libtorch set in
/TorchSharp/src/Redist/libtorch-cpu
and got this error:
build failed with 2 error(s) (0.9s)
collect2 : error : ld returned 1 exit status
/TorchSharp/src/Native/build.proj(40,5): error MSB3073: The command ""/TorchSharp/src/Native/build.sh" --configuration Release --arch arm64 --libtorchpath /TorchSharp/bin/obj/AnyCPU.Release/libtorch-cpu/libtorch-cxx11-abi-shared-with-deps-2.7.1cpu/libtorch/share/cmake/Torch" exited with code 2.
Build failed with 2 error(s) in 4.5s
please help
Please complete the following information:
- OS: [arm64 ubuntu 24.04
- Package Type [e.g. torchsharp-cpu-linux, torchsharp-cuda-linux]
- Version [e.g. 0.105.0]
- Dominant language
- C#
- Stars
- 1.9k
- Forks
- 228
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/TorchSharp
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 56/100
dotnet/TorchSharp#1574 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
dotnet/TorchSharp#1567 ·
-
question
Difficulty 5/5 Over a week Newbie friendliness 25/100
dotnet/TorchSharp#1557 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
dotnet/TorchSharp#1545 · 1 reaction ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 42/100
dotnet/TorchSharp#1541 ·
All issues in dotnet/TorchSharp
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·