Comments (4)
@luxiant ,
Please do:
- Read the installation guide in the README.md carefully. There are some options and steps for you to do. What options have you chosen? What steps caused the issue???
- Search for closed issues to see how people solve installation issues
- If you customize the installation to fit your own computer, please let's us know your computer detail and reason you try differently.
We don't know anything about your main.go
so it's hard to guess. Perhaps, you better do
- Follow the instruction in README.md to install
- Step1: Install libtorch for CPU or CUDA (by executing the script, you don't have to manually download anything)
- Step 2: Install gotch
- If there's no errors after following the above, a simple example to test gotch is:
mkdir test-gotch
cd test-gotch
go mod init "github.com/YOUR_ACCOUNT/foo"
go get "github.com/sugarme/[email protected]"
touch main.go
Then edit main.go
as
package main
import (
"fmt"
"github.com/sugarme/gotch"
"github.com/sugarme/gotch/ts"
)
func main() {
x := ts.MustRandn([]int64{3, 4, 5}, gotch.Float, gotch.CPU)
fmt.Printf("%0.3f", x)
}
Finally, run go run .
, you should see something like this in your console:
go run .
(1,.,.) =
-0.680 -0.445 0.392 0.113 -2.019
-1.062 -2.622 -1.193 -0.780 -0.560
-1.403 -0.499 -1.426 1.095 -0.081
-0.840 0.328 1.592 1.049 -0.014
(2,.,.) =
0.138 -0.884 0.102 0.097 0.750
1.239 0.009 -0.770 0.311 0.028
-0.241 0.164 1.282 -1.514 0.962
1.399 1.108 1.595 1.703 1.317
(3,.,.) =
-0.092 0.748 0.305 0.935 0.243
-0.765 -1.552 -0.242 0.384 -1.012
-0.060 1.029 -0.082 1.520 0.849
1.541 -0.532 -0.558 -0.547 -0.052
from gotch.
If you read the closed issues, you will see someone has reported this issue and solved. It's because somehow your system did not pickup your option CUDA_VER=cpu
or have you set it up before running setup-gotch.sh
?
As by default, cgo flags in gotch are set for CUDA support when you choose to use CPU, the setup-gotch.sh
script will update file cgo flags of gotch package before the linking process. The error you had was because cgo flags were still set for CUDA and linker followed such instruction and looked for cuda files in libtorch while you installed libtorch version for CPU in previous step.
A quick way to fix is manually updating file lib.go
. You can do as following:
cd $GOPATH/pkg/mod/github.com/sugarme/[email protected]/libtch
- Open
lib.go
file with your editor of choice and update it with
package libtch
// #cgo CFLAGS: -I${SRCDIR} -O3 -Wall -Wno-unused-variable -Wno-deprecated-declarations -Wno-c++11-narrowing -g -Wno-sign-compare -Wno-unused-function
// #cgo CFLAGS: -I/usr/local/include
// #cgo CFLAGS: -D_GLIBCXX_USE_CXX11_ABI=1
// #cgo LDFLAGS: -lstdc++ -ltorch -lc10 -ltorch_cpu -L/lib64
// #cgo CXXFLAGS: -std=c++17 -I${SRCDIR} -g -O3
// #cgo CFLAGS: -I${SRCDIR}/libtorch/lib -I${SRCDIR}/libtorch/include -I${SRCDIR}/libtorch/include/torch/csrc/api/include -I${SRCDIR}/libtorch/include/torch/csrc
// #cgo LDFLAGS: -L${SRCDIR}/libtorch/lib
// #cgo CXXFLAGS: -I${SRCDIR}/libtorch/lib -I${SRCDIR}/libtorch/include -I${SRCDIR}/libtorch/include/torch/csrc/api/include -I${SRCDIR}/libtorch/include/torch/csrc
import "C"
Then try to run the setup example that I mentioned previously.
Hope that works for you. Let's me know the result. Ta.
from gotch.
Excuse me for the late reply. I repeated installation but failed several times. But I tried in the different machine with docker environment on WSL ubuntu and it worked well. So I can proceed my project. I assume that the cause may be related to the conflict of the two libtorch setups, since that is the only difference compared to former trials.
By the way, is it possible to run this package on ROCM? I made it on cpu, but I haven't tried yet. I'm using AMD graphics card, so I would like to try this.
from gotch.
Thanks for your feedback and glad that you can run gotch in your box.
With regard to ROCm, gotch has not supported yet.
I am closing this issue for now.
from gotch.
Related Issues (20)
- v2.0 support HOT 3
- Possible Memory Leak From C.malloc(0) HOT 3
- how to load model pytorch_model.bin HOT 5
- Indexing documentation HOT 1
- Can't build project with gotch v0.9.0 HOT 3
- Production use for gotch just for inference HOT 3
- Concurrency issue in generating tensor name in newTensor HOT 3
- Can memory leak in tensor-generated.go because of malloc(0) ? HOT 8
- Memory Leak in JIT Model under Multi-Goroutine Environment HOT 9
- how can i convert gocv.Mat image data to Tensor ? HOT 2
- `*ts.CModule` does not implement `ts.Module` interface correctly
- Cannot Run the Application with Cgo HOT 1
- Cannot Run the Application using Libtorch 2.1 (CPU) Docker Image
- Consider using build tags instead of a bash script HOT 6
- TestOptimizer is flaky
- install steps on macos HOT 3
- Cgo Memory Leak HOT 14
- Q) Is there a function or method to clear the cached memory? HOT 1
- Float64Values() shows an error 'Unsupported Go type: []float64' HOT 2
- Releasing tensor causes segmentation fault error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotch.