-
Notifications
You must be signed in to change notification settings - Fork 5
LibTorch #187
Comments
I would suggest prioritizing this one. pytorch is one of mostly popular on Github Trending: |
´The following snipped packages the prebuilt binaries into your conan cache
runs the following code from conans import ConanFile, CMake, tools
class Libtorch(ConanFile):
name = "libtorch"
version = "1.0.0"
license = "need to be filled"
url = "https://pytorch.org/"
description = "need to be filled"
settings = "os"
options = {"cuda": ["8.0", "9.0","10.0", "None"],
"nightly":["True", "False"]}
default_options = {"cuda": "None",
"nightly": "False"}
generators = "cmake"
url_base = "https://download.pytorch.org/libtorch/"
def getGPU(self):
if(self.options.cuda == "8.0"):
return "cu80/"
if(self.options.cuda == "9.0"):
return "cu90/"
if(self.options.cuda == "10.0"):
return "cu100/"
else:
return "cpu/"
def getNightly(self):
if(self.options.nightly == "True"):
return "nightly/"
else:
return ""
def getOS(self):
if(self.settings.os == "Windows"):
return "libtorch-win-shared-with-deps-latest.zip"
if(self.settings.os == "Linux"):
return "libtorch-shared-with-deps-latest.zip"
if(self.settings.os == "MacOS"):
return "libtorch-macos-latest.zip"
def build(self):
url = self.url_base + self.getNightly() + self.getGPU() + self.getOS()
tools.get(url)
def package(self):
self.copy("*", src="libtorch/") |
Based on @PinkySan , I write a recipe that supports from conans import ConanFile, CMake, tools
from conans.util.env_reader import get_env
import os
import tempfile
class Libtorch(ConanFile):
name = "libtorch"
version = "nightly"
license = "https://raw.githubusercontent.com/pytorch/pytorch/master/LICENSE"
url = "https://pytorch.org/"
description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration"
settings = "os", "build_type"
options = {"cuda": ["8.0", "9.0", "10.0", "None"]}
default_options = {"cuda": "None"}
generators = "cmake"
url_base = "https://download.pytorch.org/libtorch/nightly"
def getGPU(self):
if self.settings.os == 'Macos':
return 'cpu'
if self.options.cuda == "8.0":
return "cu80"
if self.options.cuda == "9.0":
return "cu90"
if self.options.cuda == "10.0":
return "cu100"
else:
return "cpu"
def getOS(self):
if self.settings.os == "Windows":
if self.settings.build_type == 'Debug' and self.options.cuda != '8.0':
return "libtorch-win-shared-with-deps-debug-latest.zip"
else:
return "libtorch-win-shared-with-deps-latest.zip"
if self.settings.os == "Linux":
return "libtorch-shared-with-deps-latest.zip"
if self.settings.os == "Macos":
return "libtorch-macos-latest.zip"
def build(self):
name = f'{self.getGPU()}-{self.getOS()}'
targetfile = os.path.join(tempfile.gettempdir(), name)
if os.path.exists(targetfile) and not get_env('TORCH_FORCE_DOWNLOAD', False):
self.output.info(f'Skipping download. Using cached {targetfile}')
else:
url = f'{self.url_base}/{self.getGPU()}/{self.getOS()}'
self.output.info(f'Downloading libtorch from {url} to {targetfile}')
tools.download(url, targetfile)
tools.unzip(targetfile)
def package(self):
self.copy("*", src="libtorch/")
def package_info(self):
self.cpp_info.libs = ['torch', 'caffe2', 'c10', 'pthread']
self.cpp_info.includedirs = ['include', 'include/torch/csrc/api/include']
self.cpp_info.bindirs = ['bin']
self.cpp_info.libdirs = ['lib']
if self.options.cuda != 'None':
self.cpp_info.libs.extend(
['cuda', 'nvrtc', 'nvToolsExt', 'cudart', 'caffe2_gpu',
'c10_cuda', 'cufft', 'curand', 'cudnn', 'culibos', 'cublas']) Then in your
You have to set |
hi @PinkySan @wumo |
Sounds good. What are the requirements for a recipe? |
Started a pull request in: conan-io/conan-center-index#169 |
@PinkySan well done. I can't do better! |
Have been testing the version within my appveyor + libtorch repository. |
Any update on this one? tflite, onnx and pytorch would be a huge plus for conan, from C++ deep learning developers point of view. |
There are still dependencies missing conan-io/conan-center-index#4427 @SpaceIm seems to work towards this, but I'm sure @SpaceIm won't mind help 😄 |
Here is the PR for libtorch: conan-io/conan-center-index#5100 Since CI of conan-center-index can't build it for the moment, I also try several configurations here: https://github.com/SpaceIm/conan-libtorch |
Can be closed in favor of conan-io/conan-center-index#6861 |
I have a problem when using pre-built packages in conan: https://stackoverflow.com/questions/72197623/problem-about-buiding-a-conan-package-for-libtorch |
This is not the right repository for submitting these issues, but conan-center-index one. |
conan-center-index is not the right repository either, there is no libtorch recipe in conan-center. |
C++ API for Pytorch.
Code is included in the pytorch repo: https://github.com/pytorch/pytorch
How to build: https://michhar.github.io/how-i-built-pytorch-gpu/
Useful for deep learning projects.
The text was updated successfully, but these errors were encountered: