GithubHelp home page GithubHelp logo

Comments (8)

LaurentMazare avatar LaurentMazare commented on September 23, 2024 1

Glad that it worked, I've actually already switched the github code to use cc by default (this actually was the case a couple days ago) and have the possibility to use cmake via some environment variable.

from tch-rs.

ehsanmok avatar ehsanmok commented on September 23, 2024 1

I'm working on improving the build.rs. I'll send it today.

from tch-rs.

LaurentMazare avatar LaurentMazare commented on September 23, 2024

Hi,
Thanks for the feedback, yes CI would certainly be a good thing to add.
Re your compilation error, I haven't encountered it despite trying the pre-built cpu version 1.0.0 and 1.0.1 (as per build-version).
Is it on linux or on another platform ? I only tried linux on my side.

from tch-rs.

ehsanmok avatar ehsanmok commented on September 23, 2024

Yes, it was on Ubuntu 14.04 with cmake 3.2 and Rust nightly 1.34

from tch-rs.

LaurentMazare avatar LaurentMazare commented on September 23, 2024

Interesting, googling a bit the closest I found to your error is this issue. Not sure whether it's related but if it's the case updating to cmake 3.5.1 may fix the issue.

Alternatively you can try using the cc crate rather than cmake to compile. This can be done by replacing build.rs with the following. If this works for you we can either switching to cc or having an environment variable to decide between cc and cmake.

use std::env;
use std::path::PathBuf;
extern crate cc;

fn main() {
    let libtorch = env::var("LIBTORCH").expect("LIBTORCH not defined");
    let libtorch = PathBuf::from(libtorch);
    let libtorch_lib = libtorch.join("lib").into_os_string().into_string().unwrap();
    println!("cargo:rustc-link-search=native={}", libtorch_lib);
    println!("cargo:rustc-link-lib=c10");
    println!("cargo:rustc-link-lib=caffe2");
    println!("cargo:rustc-link-lib=torch");
    cc::Build::new()
        .cpp(true)
        .include(libtorch.join("include"))
        .include(libtorch.join("include/torch/csrc/api/include"))
        .flag(&format!("-Wl,-rpath={}", libtorch_lib))
        .flag("-std=c++11")
        .flag("-D_GLIBCXX_USE_CXX11_ABI=0")
        .file("libtch/torch_api.cpp")
        .warnings(false)
        .compile("libtorch");
}

You will also have to add the following line to Cargo.toml build-dependencies section:

cc = "1.0"

from tch-rs.

ehsanmok avatar ehsanmok commented on September 23, 2024

cc worked! also upgraded my cmake to the latest v3.14 and it worked as well.

I think, cc is more self-contained and can have it as fallback.

from tch-rs.

LaurentMazare avatar LaurentMazare commented on September 23, 2024

Cool!
Note that I changed it quite a bit lately: there is now a separate torch-sys crate (in the same repo). When the LIBTORCH variable is not set the build script will automatically download the binary version of libtorch - this is similar to what the tensorflow crate does for tf. The nice thing is that if you're happy with running the cpu version of libtorch, there is no setup needed anymore.

from tch-rs.

LaurentMazare avatar LaurentMazare commented on September 23, 2024

Closing this now, thanks for your help on this and feel free to re-open if there are further issues!

from tch-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.