René's URL Explorer Experiment


Title: Installing C++ Distributions of PyTorch — PyTorch main documentation

direct link

Domain: pytorch.org


Hey, it has json ld scripts:
    {
       "@context": "https://schema.org",
       "@type": "Article",
       "name": "Installing C++ Distributions of PyTorch",
       "headline": "Installing C++ Distributions of PyTorch",
       "description": "PyTorch Documentation. Explore PyTorch, an open-source machine learning library that accelerates the path from research prototyping to production deployment. Discover tutorials, API references, and guides to help you build and deploy deep learning models efficiently.",
       "url": "/installing.html",
       "articleBody": "Installing C++ Distributions of PyTorch# We provide binary distributions of all headers, libraries and CMake configuration files required to depend on PyTorch. We call this distribution LibTorch, and you can download ZIP archives containing the latest LibTorch distribution on our website. Below is a small example of writing a minimal application that depends on LibTorch and uses the torch::Tensor class which comes with the PyTorch C++ API. Minimal Example# The first step is to download the LibTorch ZIP archive via the link above. For example: wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip unzip libtorch-shared-with-deps-latest.zip Note that the above link has CPU-only libtorch. If you would like to download a GPU-enabled libtorch, find the right link in the link selector on https://pytorch.org If you\u2019re a Windows developer and wouldn\u2019t like to use CMake, you could jump to the Visual Studio Extension section. Next, we can write a minimal CMake build configuration to develop a small application that depends on LibTorch. CMake is not a hard requirement for using LibTorch, but it is the recommended and blessed build system and will be well supported into the future. A most basic CMakeLists.txt file could look like this: cmake_minimum_required(VERSION 3.18 FATAL_ERROR) project(example-app) find_package(Torch REQUIRED) set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}\") add_executable(example-app example-app.cpp) target_link_libraries(example-app \"${TORCH_LIBRARIES}\") set_property(TARGET example-app PROPERTY CXX_STANDARD 17) # The following code block is suggested to be used on Windows. # According to https://github.com/pytorch/pytorch/issues/25457, # the DLLs need to be copied to avoid memory errors. if (MSVC) file(GLOB TORCH_DLLS \"${TORCH_INSTALL_PREFIX}/lib/*.dll\") add_custom_command(TARGET example-app POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TORCH_DLLS} $\u003cTARGET_FILE_DIR:example-app\u003e) endif (MSVC) The implementation of our example will simply create a new torch::Tensor and print it: #include \u003ctorch/torch.h\u003e #include \u003ciostream\u003e int main() { torch::Tensor tensor = torch::rand({2, 3}); std::cout \u003c\u003c tensor \u003c\u003c std::endl; } While there are more fine-grained headers you can include to access only parts of the PyTorch C++ API, including torch/torch.h is the most sure-proof way of including most of its functionality. The last step is to build the application. For this, assume our example directory is laid out like this: example-app/ CMakeLists.txt example-app.cpp We can now run the following commands to build the application from within the example-app/ folder: mkdir build cd build cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch .. cmake --build . --config Release where /absolute/path/to/libtorch should be the absolute (!) path to the unzipped LibTorch distribution. If PyTorch was installed via pip, CMAKE_PREFIX_PATH can be queried using torch.utils.cmake_prefix_path variable. In that case CMake configuration step would look something like follows: cmake -DCMAKE_PREFIX_PATH=`python3 -c \u0027import torch;print(torch.utils.cmake_prefix_path)\u0027` .. If all goes well, it will look something like this: root@4b5a67132e81:/example-app# mkdir build root@4b5a67132e81:/example-app# cd build root@4b5a67132e81:/example-app/build# cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch .. -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Configuring done -- Generating done -- Build files have been written to: /example-app/build root@4b5a67132e81:/example-app/build# cmake --build . --config Release Scanning dependencies of target example-app [ 50%] Building CXX object CMakeFiles/example-app.dir/example-app.cpp.o [100%] Linking CXX executable example-app [100%] Built target example-app Executing the resulting example-app binary found in the build folder should now merrily print the tensor (exact output subject to randomness): root@4b5a67132e81:/example-app/build# ./example-app 0.2063 0.6593 0.0866 0.0796 0.5841 0.1569 [ Variable[CPUFloatType]{2,3} ] Tip On Windows, debug and release builds are not ABI-compatible. If you plan to build your project in debug mode, please try the debug version of LibTorch. Also, make sure you specify the correct configuration in the cmake --build . line above. System Requirements# To ensure smooth installation and usage of LibTorch, please ensure your system meets the following requirements: GLIBC Version: GLIBC 2.29 or newer for cxx11 ABI version GCC Version: GCC 9 or newer for cxx11 Visual Studio Extension# LibTorch Project Template can help Windows developers set all libtorch project settings and link options for debug and release. It\u2019s easy to use and you could check out the demo video. The only prerequisite is to download the libtorch on https://pytorch.org Support# If you run into any troubles with this installation and minimal usage guide, please use our forum or GitHub issues to get in touch.",
       "author": {
         "@type": "Organization",
         "name": "PyTorch Contributors",
         "url": "https://pytorch.org"
       },
       "image": "https://pytorch.org/docs/stable/_static/img/pytorch_seo.png",
       "mainEntityOfPage": {
         "@type": "WebPage",
         "@id": "/installing.html"
       },
       "datePublished": "2023-01-01T00:00:00Z",
       "dateModified": "2023-01-01T00:00:00Z"
     }
 

docsearch:languageen
og:imagehttps://docs.pytorch.org/docs/stable/_static/img/pytorch_seo.png
None1

Links:

https://pytorch.org/
Get Started https://pytorch.org/get-started/locally
Tutorials https://docs.pytorch.org/tutorials
Learn the Basics https://pytorch.org/tutorials/beginner/basics/intro.html
PyTorch Recipes https://pytorch.org/tutorials/recipes/recipes_index.html
Intro to PyTorch - YouTube Series https://pytorch.org/tutorials/beginner/introyt.html
Webinars https://pytorch.org/webinars/
Landscape https://landscape.pytorch.org/
Join the Ecosystem https://pytorch.org/join-ecosystem
Community Hub https://pytorch.org/community-hub/
Forums https://discuss.pytorch.org/
Developer Resources https://pytorch.org/resources
Contributor Awards https://pytorch.org/contributor-awards/
Community Events https://pytorch.org/community-events/
PyTorch Ambassadors https://pytorch.org/programs/ambassadors/
PyTorch https://pytorch.org/projects/pytorch/
vLLM https://pytorch.org/projects/vllm/
DeepSpeed https://pytorch.org/projects/deepspeed/
Host Your Project https://pytorch.org/projects/host-your-project/
RAY https://pytorch.org/projects/ray/
PyTorch https://docs.pytorch.org/docs/stable/index.html
Domains https://pytorch.org/domains
Blog https://pytorch.org/blog/
Announcements https://pytorch.org/announcements
Case Studies Events Newsletter https://pytorch.org/case-studies/
Events https://pytorch.org/events
Newsletter https://pytorch.org/newsletter
PyTorch Foundation https://pytorch.org/foundation
Members https://pytorch.org/members
Governing Board https://pytorch.org/governing-board
Technical Advisory Council https://pytorch.org/tac
Cloud Credit Program https://pytorch.org/credits
Staff https://pytorch.org/staff
Contact https://pytorch.org/contact
Brand Guidelines https://pytorch.org/wp-content/uploads/2025/09/pytorch_brand_guide_091925a.pdf
JOIN https://pytorch.org/join
https://pytorch.org/cppdocs/installing.html
https://pytorch.org/cppdocs/installing.html
Get Startedhttps://pytorch.org/get-started/locally
Tutorialshttps://docs.pytorch.org/tutorials
Learn the Basicshttps://pytorch.org/tutorials/beginner/basics/intro.html
PyTorch Recipeshttps://pytorch.org/tutorials/recipes/recipes_index.html
Introduction to PyTorch - YouTube Serieshttps://pytorch.org/tutorials/beginner/introyt.html
Webinarshttps://pytorch.org/webinars/
Landscapehttps://landscape.pytorch.org/
Join the Ecosystemhttps://pytorch.org/join-ecosystem
Community Hubhttps://pytorch.org/community-hub/
Forumshttps://discuss.pytorch.org/
Developer Resourceshttps://pytorch.org/resources
Contributor Awardshttps://pytorch.org/contributor-awards/
Community Eventshttps://pytorch.org/community-events/
PyTorch Ambassadorshttps://pytorch.org/programs/ambassadors/
PyTorchhttps://pytorch.org/projects/pytorch/
vLLMhttps://pytorch.org/projects/vllm/
DeepSpeedhttps://pytorch.org/projects/deepspeed/
Host Your Projecthttps://pytorch.org/projects/host-your-project/
PyTorchhttps://docs.pytorch.org/docs/stable/index.html
Domainshttps://pytorch.org/domains
Bloghttps://pytorch.org/blog/
Announcementshttps://pytorch.org/announcements
Case Studieshttps://pytorch.org/case-studies/
Eventshttps://pytorch.org/events
Newsletterhttps://pytorch.org/newsletter
PyTorch Foundationhttps://pytorch.org/foundation
Membershttps://pytorch.org/members
Governing Boardhttps://pytorch.org/governing-board
Technical Advisory Councilhttps://pytorch.org/tac
Cloud Credit Programhttps://pytorch.org/credits
Staffhttps://pytorch.org/staff
Contacthttps://pytorch.org/contact
Skip to main contenthttps://pytorch.org/cppdocs/installing.html#main-content
mainhttps://pytorch.org/cppdocs/index.html
Installing C++ Distributions of PyTorch https://pytorch.org/cppdocs/installing.html
The C++ Frontend https://pytorch.org/cppdocs/frontend.html
Torch Stable API https://pytorch.org/cppdocs/stable.html
Library API https://pytorch.org/cppdocs/api/library_root.html
FAQ https://pytorch.org/cppdocs/notes/faq.html
Inference Mode https://pytorch.org/cppdocs/notes/inference_mode.html
MaybeOwned https://pytorch.org/cppdocs/notes/maybe_owned.html
Tensor Basics https://pytorch.org/cppdocs/notes/tensor_basics.html
Tensor Creation API https://pytorch.org/cppdocs/notes/tensor_creation.html
Tensor CUDA Stream API https://pytorch.org/cppdocs/notes/tensor_cuda_stream.html
Tensor Indexing API https://pytorch.org/cppdocs/notes/tensor_indexing.html
Library Versioning https://pytorch.org/cppdocs/notes/versioning.html
Xhttps://x.com/PyTorch
GitHubhttps://github.com/pytorch/pytorch
PyTorch Forumhttps://discuss.pytorch.org/
PyPihttps://pypi.org/project/torch/
Installing C++ Distributions of PyTorch https://pytorch.org/cppdocs/installing.html
The C++ Frontend https://pytorch.org/cppdocs/frontend.html
Torch Stable API https://pytorch.org/cppdocs/stable.html
Library API https://pytorch.org/cppdocs/api/library_root.html
FAQ https://pytorch.org/cppdocs/notes/faq.html
Inference Mode https://pytorch.org/cppdocs/notes/inference_mode.html
MaybeOwned https://pytorch.org/cppdocs/notes/maybe_owned.html
Tensor Basics https://pytorch.org/cppdocs/notes/tensor_basics.html
Tensor Creation API https://pytorch.org/cppdocs/notes/tensor_creation.html
Tensor CUDA Stream API https://pytorch.org/cppdocs/notes/tensor_cuda_stream.html
Tensor Indexing API https://pytorch.org/cppdocs/notes/tensor_indexing.html
Library Versioning https://pytorch.org/cppdocs/notes/versioning.html
Xhttps://x.com/PyTorch
GitHubhttps://github.com/pytorch/pytorch
PyTorch Forumhttps://discuss.pytorch.org/
PyPihttps://pypi.org/project/torch/
https://pytorch.org/cppdocs/index.html
#https://pytorch.org/cppdocs/installing.html#installing-c-distributions-of-pytorch
our websitehttps://pytorch.org/get-started/locally/
#https://pytorch.org/cppdocs/installing.html#minimal-example
https://pytorch.orghttps://pytorch.org
#https://pytorch.org/cppdocs/installing.html#system-requirements
#https://pytorch.org/cppdocs/installing.html#visual-studio-extension
LibTorch Project Templatehttps://marketplace.visualstudio.com/items?itemName=YiZhang.LibTorch001
demo videohttps://ossci-windows.s3.us-east-1.amazonaws.com/vsextension/demo.mp4
https://pytorch.orghttps://pytorch.org
#https://pytorch.org/cppdocs/installing.html#support
forumhttps://discuss.pytorch.org/
GitHub issueshttps://github.com/pytorch/pytorch/issues
previous PyTorch C++ API https://pytorch.org/cppdocs/index.html
next The C++ Frontend https://pytorch.org/cppdocs/frontend.html
PyData Sphinx Themehttps://pydata-sphinx-theme.readthedocs.io/en/stable/index.html
previous PyTorch C++ API https://pytorch.org/cppdocs/index.html
next The C++ Frontend https://pytorch.org/cppdocs/frontend.html
Minimal Examplehttps://pytorch.org/cppdocs/installing.html#minimal-example
System Requirementshttps://pytorch.org/cppdocs/installing.html#system-requirements
Visual Studio Extensionhttps://pytorch.org/cppdocs/installing.html#visual-studio-extension
Supporthttps://pytorch.org/cppdocs/installing.html#support
Show Source https://pytorch.org/cppdocs/_sources/installing.rst.txt
torchaohttps://docs.pytorch.org/ao
torchrechttps://docs.pytorch.org/torchrec
torchfthttps://docs.pytorch.org/torchft
TorchCodechttps://docs.pytorch.org/torchcodec
torchvisionhttps://docs.pytorch.org/vision
ExecuTorchhttps://docs.pytorch.org/executorch
PyTorch on XLA Deviceshttps://docs.pytorch.org/xla
View Docshttps://docs.pytorch.org/docs/stable/index.html
View Tutorialshttps://docs.pytorch.org/tutorials
View Resourceshttps://pytorch.org/resources
Privacy Policyhttps://www.linuxfoundation.org/privacy/
https://www.facebook.com/pytorch
https://twitter.com/pytorch
https://www.youtube.com/pytorch
https://www.linkedin.com/company/pytorch
https://pytorch.slack.com
https://pytorch.org/wechat
Policieshttps://www.linuxfoundation.org/legal/policies
Trademark Usagehttps://www.linuxfoundation.org/trademark-usage
Privacy Policyhttp://www.linuxfoundation.org/privacy
Cookies Policyhttps://www.facebook.com/policies/cookies/
Sphinxhttps://www.sphinx-doc.org/
PyData Sphinx Themehttps://pydata-sphinx-theme.readthedocs.io/en/stable/index.html

Viewport: width=device-width, initial-scale=1


URLs of crawlers that visited me.