在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):hasktorch/hasktorch开源软件地址(OpenSource Url):https://github.com/hasktorch/hasktorch开源编程语言(OpenSource Language):Haskell 98.7%开源软件介绍(OpenSource Introduction):HasktorchHasktorch is a library for tensors and neural networks in Haskell. It is an independent open source community project which leverages the core C++ libraries shared by PyTorch. This project is in active development, so expect changes to the library API as it evolves. We would like to invite new users to join our Hasktorch slack space for questions and discussions. Contributions/PR are encouraged. Currently we are developing the second major release of Hasktorch (0.2). Note the 1st release, Hasktorch 0.1, on hackage is outdated and should not be used. DocumentationThe documentation is divided into several sections: Introductory Videos
Getting StartedThe following steps will get you started. They assume the hasktorch repository has just been cloned. After setup is done, read the online tutorials and API documents.
linux+cabal+cpuStarting from the top-level directory of the project, run: $ pushd deps # Change to the deps directory and save the current directory.
$ ./get-deps.sh # Run the shell script to retrieve the libtorch dependencies.
$ popd # Go back to the root directory of the project.
$ source setenv # Set the shell environment to reference the shared library locations.
$ ./setup-cabal.sh # Create a cabal project file To build and test the Hasktorch library, run: $ cabal build hasktorch # Build the Hasktorch library.
$ cabal test hasktorch # Build and run the Hasktorch library test suite. To build and test the example executables shipped with hasktorch, run: $ cabal build examples # Build the Hasktorch examples.
$ cabal test examples # Build and run the Hasktorch example test suites. To run the MNIST CNN example, run: $ cd examples # Change to the examples directory.
$ ./datasets/download-mnist.sh # Download the MNIST dataset.
$ mv mnist data # Move the MNIST dataset to the data directory.
$ export DEVICE=cpu # Set device to CPU for the MNIST CNN example.
$ cabal run static-mnist-cnn # Run the MNIST CNN example. linux+cabal+cuda11Starting from the top-level directory of the project, run: $ pushd deps # Change to the deps directory and save the current directory.
$ ./get-deps.sh -a cu113 # Run the shell script to retrieve the libtorch dependencies.
$ popd # Go back to the root directory of the project.
$ source setenv # Set the shell environment to reference the shared library locations.
$ ./setup-cabal.sh # Create a cabal project file To build and test the Hasktorch library, run: $ cabal build hasktorch # Build the Hasktorch library.
$ cabal test hasktorch # Build and run the Hasktorch library test suite. To build and test the example executables shipped with hasktorch, run: $ cabal build examples # Build the Hasktorch examples.
$ cabal test examples # Build and run the Hasktorch example test suites. To run the MNIST CNN example, run: $ cd examples # Change to the examples directory.
$ ./datasets/download-mnist.sh # Download the MNIST dataset.
$ mv mnist data # Move the MNIST dataset to the data directory.
$ export DEVICE="cuda:0" # Set device to CUDA for the MNIST CNN example.
$ cabal run static-mnist-cnn # Run the MNIST CNN example. macos+cabal+cpuStarting from the top-level directory of the project, run: $ pushd deps # Change to the deps directory and save the current directory.
$ ./get-deps.sh # Run the shell script to retrieve the libtorch dependencies.
$ popd # Go back to the root directory of the project.
$ source setenv # Set the shell environment to reference the shared library locations.
$ ./setup-cabal.sh # Create a cabal project file To build and test the Hasktorch library, run: $ cabal build hasktorch # Build the Hasktorch library.
$ cabal test hasktorch # Build and run the Hasktorch library test suite. To build and test the example executables shipped with hasktorch, run: $ cabal build examples # Build the Hasktorch examples.
$ cabal test examples # Build and run the Hasktorch example test suites. To run the MNIST CNN example, run: $ cd examples # Change to the examples directory.
$ ./datasets/download-mnist.sh # Download the MNIST dataset.
$ mv mnist data # Move the MNIST dataset to the data directory.
$ export DEVICE=cpu # Set device to CPU for the MNIST CNN example.
$ cabal run static-mnist-cnn # Run the MNIST CNN example. linux+stack+cpuInstall the Haskell Tool Stack if you haven't already, following instructions here Starting from the top-level directory of the project, run: $ pushd deps # Change to the deps directory and save the current directory.
$ ./get-deps.sh # Run the shell script to retrieve the libtorch dependencies.
$ popd # Go back to the root directory of the project.
$ source setenv # Set the shell environment to reference the shared library locations. To build and test the Hasktorch library, run: $ stack build hasktorch # Build the Hasktorch library.
$ stack test hasktorch # Build and run the Hasktorch library test suite. To build and test the example executables shipped with hasktorch, run: $ stack build examples # Build the Hasktorch examples.
$ stack test examples # Build and run the Hasktorch example test suites. To run the MNIST CNN example, run: $ cd examples # Change to the examples directory.
$ ./datasets/download-mnist.sh # Download the MNIST dataset.
$ mv mnist data # Move the MNIST dataset to the data directory.
$ export DEVICE=cpu # Set device to CPU for the MNIST CNN example.
$ stack run static-mnist-cnn # Run the MNIST CNN example. macos+stack+cpuInstall the Haskell Tool Stack if you haven't already, following instructions here Starting from the top-level directory of the project, run: $ pushd deps # Change to the deps directory and save the current directory.
$ ./get-deps.sh # Run the shell script to retrieve the libtorch dependencies.
$ popd # Go back to the root directory of the project.
$ source setenv # Set the shell environment to reference the shared library locations. To build and test the Hasktorch library, run: $ stack build hasktorch # Build the Hasktorch library.
$ stack test hasktorch # Build and run the Hasktorch library test suite. To build and test the example executables shipped with hasktorch, run: $ stack build examples # Build the Hasktorch examples.
$ stack test examples # Build and run the Hasktorch example test suites. To run the MNIST CNN example, run: $ cd examples # Change to the examples directory.
$ ./datasets/download-mnist.sh # Download the MNIST dataset.
$ mv mnist data # Move the MNIST dataset to the data directory.
$ export DEVICE=cpu # Set device to CPU for the MNIST CNN example.
$ stack run static-mnist-cnn # Run the MNIST CNN example. nixos+cabal+cpu(Optional) Install and set up Cachix: $ nix-env -iA cachix -f https://cachix.org/api/v1/install # (Optional) Install Cachix.
# (Optional) Use IOHK's cache. See https://input-output-hk.github.io/haskell.nix/tutorials/getting-started/#setting-up-the-binary-cache
$ cachix use hasktorch # (Optional) Use hasktorch's cache. Starting from the top-level directory of the project, run: $ nix develop # Enter the nix shell environment for Hasktorch. To build and test the Hasktorch library, run: $ cabal build hasktorch # Build the Hasktorch library.
$ cabal test hasktorch # Build and run the Hasktorch library test suite. To build and test the example executables shipped with hasktorch, run: $ cabal build examples # Build the Hasktorch examples.
$ cabal test examples # Build and run the Hasktorch example test suites. To run the MNIST CNN example, run: $ cd examples # Change to the examples directory.
$ ./datasets/download-mnist.sh # Download the MNIST dataset.
$ mv mnist data # Move the MNIST dataset to the data directory.
$ export DEVICE=cpu # Set device to CPU for the MNIST CNN example.
$ cabal run static-mnist-cnn # Run the MNIST CNN example. nixos+cabal+cuda11(Optional) Install and set up Cachix: $ nix-env -iA cachix -f https://cachix.org/api/v1/install # (Optional) Install Cachix.
# (Optional) Use IOHK's cache. See https://input-output-hk.github.io/haskell.nix/tutorials/getting-started/#setting-up-the-binary-cache
$ cachix use hasktorch # (Optional) Use hasktorch's cache. Starting from the top-level directory of the project, run: $ cat > nix/dev-config.nix
{
profiling = true;
cudaSupport = true;
cudaMajorVersion = "11";
}
$ nix develop # Enter the nix shell environment for Hasktorch. To build and test the Hasktorch library, run: $ cabal build hasktorch # Build the Hasktorch library.
$ cabal test hasktorch # Build and run the Hasktorch library test suite. To build and test the example executables shipped with hasktorch, run: $ cabal build examples # Build the Hasktorch examples.
$ cabal test examples # Build and run the Hasktorch example test suites. To run the MNIST CNN example, run: $ cd examples # Change to the examples directory.
$ ./datasets/download-mnist.sh # Download the MNIST dataset.
$ mv mnist data # Move the MNIST dataset to the data directory.
$ export DEVICE="cuda:0" # Set device to CUDA for the MNIST CNN example.
$ cabal run static-mnist-cnn # Run the MNIST CNN example. docker+jupyterlab+cuda11This dockerhub repository provides the docker-image of jupyterlab. It supports cuda11, cuda10 and cpu only. When you use jupyterlab with hasktorch, type following command, then click a url in a console. $ docker run --gpus all -it --rm -p 8888:8888 htorch/hasktorch-jupyter
or
$ docker run --gpus all -it --rm -p 8888:8888 htorch/hasktorch-jupyter:latest-cu11 Known IssuesTensors Cannot Be Moved to CUDAIn rare cases, you may see errors like
although you have CUDA capable hardware in your machine and have followed the getting-started instructions for CUDA support. If that happens, check if Weird Behaviour When Switching from CPU-Only to CUDA-Enabled Nix ShellIf you have run
Otherwise, at best, you will not be able to move tensors to CUDA, and, at worst, you will see weird linker errors like
ContributingWe welcome new contributors. Contact us for access to the hasktorch slack channel. You can send an email to [email protected] or on twitter as @austinvhuang, @SamStites, @tscholak, or @junjihashimoto3. Notes for library developersSee the wiki for developer notes. Project Folder StructureBasic functionality:
Internals (for contributing developers):
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论