Giter Site home page Giter Site logo

fepegar / slicerpytorch Goto Github PK

View Code? Open in Web Editor NEW
30.0 7.0 5.0 489 KB

This extension contains only a module with some tools to install PyTorch inside Slicer, using the best possible version.

License: Other

CMake 15.47% Python 84.53%
3d-slicer-extension

slicerpytorch's Introduction

SlicerPyTorch

SlicerPyTorch logo

This is the code for the PyTorch extension for 3D Slicer.

Its main function is to install PyTorch inside Slicer. The latest version compatible with the installed drivers will be selected automatically. CI tests are run nightly.

PyTorch can be installed opening the PyTorch Utils module and clicking on the button, or programmatically:

import PyTorchUtils
torch = PyTorchUtils.PyTorchUtilsLogic().torch  # will be installed if necessary
tensor = torch.rand(50, 60)

Unit tests are run nightly and the results can be checked on CDash.

Here's a diagram of the integration between PyTorch and Slicer:

Diagram of PyTorch and Slicer

slicerpytorch's People

Contributors

fedesemeraro avatar fepegar avatar jcfr avatar lassoan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

slicerpytorch's Issues

torch 1.x is installed by default

For some reason, on some configurations, this extension installs pytorch-1.x by default, which is a problem, because the most widely used AI segmentation tool, TotalSegmentator only works with pytorch>=2.x.

@fepegar, do you have any clue why not the latest version is installed by default?
Could we hardcode the torch>=2 version requirement in the installation parameters?

OSError: [WinError 127] Error loading "torch_cuda_cpp.dll" or one of its dependencies.

I succesfully download the PyTorch module.
However, when I import torch,it returns a OSError below.

How can I fix this bug?

  • Slicer Version:4.13.0-2021-11-20
  • OS: Windows10
>>> import torch
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\Lenovo\AppData\Local\NA-MIC\Slicer 4.13.0-2021-11-20\lib\Python\Lib\site-packages\torch\__init__.py", line 124, in <module>
    raise err
OSError: [WinError 127] 找不到指定的程序。 Error loading "C:\Users\Lenovo\AppData\Local\NA-MIC\Slicer 4.13.0-2021-11-20\lib\Python\Lib\site-packages\torch\lib\torch_cuda_cpp.dll" or one of its dependencies.

torch 1.x is installed by default

For some reason, on some configurations, this extension installs pytorch-1.x by default, which is a problem, because the most widely used AI segmentation tool, TotalSegmentator only works with pytorch>=2.x.

@fepegar, do you have any clue why not the latest version is installed by default?
Could we hardcode the torch>=2 version requirement in the installation parameters?

Add option to ask user confirmation to install pytorch

Pytorch may take significant space and time to download and install. Therefore, it would be nice if a module that relies on pytorch asked approval from the user. Something like this:

slicer.util.confirmOkCancelDisplay("This module requires 'pytorch' Python package. Click OK to install it now.")

There could be a silent option to install pytorch without asking the user.

New logo

I asked the PyTorch team if they are happy with the logo. They said:

Using the PyTorch logo is allowed but there are some guidelines that you would need to follow. For example, altering the PyTorch logo to create another logo is not allowed and also there need to be clear spaces around the PyTorch logo.
Since you have already created the logo, it might be difficult to update but would any of the recommendations below work?
unnamed

In another iteration, they said they would also be happy with the Slicer logo being smaller, or the same size, as the PyTorch logo. Basically, they need to be separate.

@lassoan, @pieper, @jcfr what do you think is best? I asked them if they were happy with the logo before sharing the extension on e.g. the PyTorch forum.

Failed test case due to missing attribute landmarksPath

See testing results at https://slicer.cdash.org/test/20203689

======================================================================
ERROR: test_PyTorchUtils (PyTorchUtils.PyTorchUtilsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:/D/P/S-0-E-b/PyTorch-build/lib/Slicer-4.13/qt-scripted-modules/PyTorchUtils.py", line 127, in tearDown
    self.landmarksPath.unlink()
AttributeError: 'PyTorchUtilsTest' object has no attribute 'landmarksPath'

Also a little weird that light-the-torch is pinning pip to a certain version (pmeier/light-the-torch@24cd474) which is why Slicer it having to uninstall pip to use an older version.

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.