{"id":15400717,"url":"https://github.com/dbraun/pytorchtop-cpumem","last_synced_at":"2025-04-15T22:30:47.966Z","repository":{"id":75114012,"uuid":"241936138","full_name":"DBraun/PyTorchTOP-cpumem","owner":"DBraun","description":"PyTorch / libtorch in TouchDesigner based on the CPUMemoryTOP example.","archived":false,"fork":false,"pushed_at":"2021-01-31T05:54:11.000Z","size":25082,"stargazers_count":52,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T03:22:00.426Z","etag":null,"topics":["libtorch","pytorch","touchdesigner"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DBraun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-20T16:41:26.000Z","updated_at":"2024-09-29T19:09:20.000Z","dependencies_parsed_at":"2023-06-05T10:00:31.283Z","dependency_job_id":null,"html_url":"https://github.com/DBraun/PyTorchTOP-cpumem","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":"0.46153846153846156","last_synced_commit":"bc1c55bfbca36bce069ab51582e16c20e9107a36"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DBraun%2FPyTorchTOP-cpumem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DBraun%2FPyTorchTOP-cpumem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DBraun%2FPyTorchTOP-cpumem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DBraun%2FPyTorchTOP-cpumem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DBraun","download_url":"https://codeload.github.com/DBraun/PyTorchTOP-cpumem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249165872,"owners_count":21223340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["libtorch","pytorch","touchdesigner"],"created_at":"2024-10-01T15:54:46.119Z","updated_at":"2025-04-15T22:30:42.956Z","avatar_url":"https://github.com/DBraun.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyTorchTOP\n![](docs/trillium_mosaic.jpg)\n\n**Update December 27, 2020: a GPU version of PyTorchTOP has been released [here](https://github.com/DBraun/PyTorchTOP). This [branch](https://github.com/DBraun/PyTorchTOP/tree/model/style-transfer) demonstrates Style Transfer.**\n\n## Installation on Windows (no OSX support)\n\n### Download LibTorch\nFrom [https://pytorch.org/](https://pytorch.org/) download, 1.4 (stable), Windows, LibTorch, C++/Java, CUDA 10.1\n\n### TouchDesigner Hack :/\nI've tested TouchDesigner 2020.22080. From the place where you downloaded LibTorch, go to `libtorch\\lib`. Then take `libiomp5md.dll` and overwrite the `libiomp5md.dll` for your TouchDesigner: `C:\\Program Files\\Derivative\\TouchDesigner099\\bin`.\n\nDownload `PyTorchTOP.dll` from the [Releases](https://github.com/DBraun/PyTorchTOP-cpumem/releases) page of this repo. Place it in this repo's `Plugins` folder. Copy the DLL files from `libtorch\\lib` into `Plugins` too. Congrats! You're done and can open PyTorchTOP.toe! The remaining steps are for building `PyTorchTOP.dll`.\n\n## CUDA and CUDNN\n\nFrom NVIDIA, install CUDA 10.1, which will create `C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.1`. Download cuDNN 7.6.5 for 10.1 and place the files into this folder too.\n\n## CMake\n\nI've tested [CMake](https://cmake.org/download/) 3.15.1. Inside the root of `PyTorchTOP-cpumem`:\n\n    mkdir build_release\n    cd build_release\n    cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..\n\nwhere `/path/to/libtorch` should be the full path to the unzipped LibTorch distribution. Expected output:\n\n\t-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.\n\tx64 architecture in use\n\t-- Caffe2: CUDA detected: 10.1\n\t-- Caffe2: CUDA nvcc is: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin/nvcc.exe\n\t-- Caffe2: CUDA toolkit directory: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1\n\t-- Caffe2: Header version is: 10.1\n\t-- Found cuDNN: v7.6.5  (include: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/include, library: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/lib/x64/cudnn.lib)\n\t-- Autodetected CUDA architecture(s):  7.5\n\t-- Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75\n\t-- Configuring done\n\t-- Generating done\n\t-- Build files have been written to: /path/to/PyTorchTOP-cpumem/build_release\nIf it works, you should end up with a Visual Studio Solution `build_release\\PyTorchTOP.sln`. Open it and select the Release build. Press F5 to build the DLL and launch TouchDesigner.\n\nThe steps to build a debug-mode Visual Studio solution are similar. Instead of `build_release`, make a folder `build_debug`.\n    \n    mkdir build_debug\n    cd build_debug\n    set DEBUG=1\n    cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch-debug-version ..\n\nNow you can build `build_debug\\PyTorchTOP.sln` in Debug mode. You should copy the `.pdb` files from the libtorch-debug-version folder to this repo's `Plugins` folder in order to help with stack traces during debugging.\n\n### Neural Style Transfer\n\nThis project uses models that have been exported from [Fast Neural Style](https://github.com/pytorch/examples/tree/master/fast_neural_style). These are the steps to creating your own models. Install pytorch for python. Open `neural_style\\neural_style.py`. Look for this line\n    \n    output = style_model(content_image).cpu()\n\nBefore it, write these lines:\n\n\ttraced_script_module = torch.jit.trace(style_model, content_image)\n\ttraced_script_module.save(\"traced_model.pt\")\n\nTo save a new `traced_model.pt`, run:\n\n    python neural_style/neural_style.py eval --content-image test640x360.jpeg --model saved_models/udnie.pth --output-image myoutput.png --cuda 1\n\nNotice that you've provided a content image of a certain resolution, selected a model path, and enabled cuda. Because `test640x360.jpeg` is a 640x360 image, the newly created `traced_model.pt` will work with 640x360 images in TouchDesigner. Export a model for each size resolution you need and rename as necessary. In TouchDesigner, select the model with the custom parameter `Modelfilepath`.\n\n## Extra notes\n\nUse the channel mix TOP to swap your red channel and blue channel before sending to PyTorchTOP.\n\n## The Future\n* Fix the clumsiness of the RGBA-BGRA swapping in TouchDesigner.\n* Better handling of input resolution and output resolution. Can it be stored in the pt file?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbraun%2Fpytorchtop-cpumem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbraun%2Fpytorchtop-cpumem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbraun%2Fpytorchtop-cpumem/lists"}