Code Monkey home page Code Monkey logo

Comments (5)

davkovacs avatar davkovacs commented on August 29, 2024

I think the problem might be torch 1.12, for some reason the NNPOps still seems to only support 1.11 . My code sadly only works with 1.12. Would it be possible to change that in environment.yml ?

channels:
  - conda-forge
dependencies:
  - cmake >=3.20
  - cudatoolkit 11.2.2
  - gxx_linux-64 10.3.0
  - make
  - mdtraj
  - nvcc_linux-64 11.2
  - torchani 2.2.2
  - pytest
  - python 3.10.*
  - pytorch-gpu 1.11.0
  - sysroot_linux-64 2.17

from nnpops.

RaulPPelaez avatar RaulPPelaez commented on August 29, 2024

I cannot reproduce this. NNPOps should work with 1.12 now, though.

from nnpops.

RaulPPelaez avatar RaulPPelaez commented on August 29, 2024

I have actually been cursed with this.
I have found that manually loading the .so in getNeighborPairs.py fixes it:

from torch import  ops
import site
ops.load_library(site.getsitepackages()[-1]+"/NNPOps/libNNPOpsPyTorch.so")

It is strange, because while I observe the behavior described by @davkovacs, running pytest works. Pytest is able to load and call getNeighborPairs during the tests, but I cannot do so from a python script such as this one:

import torch as pt
import numpy as np
import pytest
from NNPOps.neighbors import getNeighborPairs

device = 'cuda:0'
dtype = pt.float32
num_atoms = 100
# Generate random positions
positions = 10 * pt.randn((num_atoms, 3), device=device, dtype=dtype)
cutoff = float(5.0)
num_neighbors = num_atoms*num_atoms
neighbors, deltas, distances = getNeighborPairs(positions, cutoff=cutoff, max_num_neighbors=num_neighbors)

I have no idea of what causes this or how to reproduce it.

from nnpops.

peastman avatar peastman commented on August 29, 2024

I think we just need to move the code to load the library?

torch.ops.load_library(os.path.join(os.path.dirname(__file__), 'libNNPOpsPyTorch.so'))
torch.classes.load_library(os.path.join(os.path.dirname(__file__), 'libNNPOpsPyTorch.so'))

It gets repeated in SymmetryFunction.py, CFConv.py, and BatchedNN.py. It doesn't appear in getNeighborPairs.py, so the library doesn't get loaded in that case. How about loading the library once, in the top level __init__.py?

from nnpops.

RaulPPelaez avatar RaulPPelaez commented on August 29, 2024

Ohhh so this is why the tests run, they must import one of those.

How about loading the library once, in the top level init.py?

I do not know what the standard knowledge is on this, but that seems sensible. Let me test and I will PR.

from nnpops.

Related Issues (20)

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.