Verified-Intelligence / alpha-beta-CROWN

alpha-beta-CROWN: An Efficient, Scalable and GPU Accelerated Neural Network Verifier (winner of VNN-COMP 2021, 2022, 2023, and 2024)
Other
243 stars 60 forks source link

Can't install #56

Closed mathisdon closed 6 months ago

mathisdon commented 6 months ago

I'm following the installation instructions, using miniconda with python 3.11 installed, on Windows. I get the error below. I must be doing something fundamentally wrong for it not to find so many packages. What am I doing wrong?

I did this:

git clone --recursive https://github.com/Verified-Intelligence/alpha-beta-CROWN.git (worked fine) conda env create -f complete_verifier/environment.yaml --name alpha-beta-crown

And the result was:

Channels:

PackagesNotFoundError: The following packages are not available from current channels:

Current channels:

To search for alternate channels that may provide the conda package you're looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

shizhouxing commented 6 months ago

Hi @mathisdon ,

It looks like you are using Windows? I guess environment.yaml we provided may not be compatible with Windows.

Alternatively, you may try using pip. There are two sets of dependencies that need to be installed:

  1. Pytorch and auto_LiRPA, as specified at https://github.com/Verified-Intelligence/auto_LiRPA?tab=readme-ov-file#installation
  2. Additional dependencies for the complete verifier: https://github.com/Verified-Intelligence/alpha-beta-CROWN/blob/main/complete_verifier/requirements.txt
mathisdon commented 6 months ago

Thank you, that worked. But now I'm trying to run your example simple_verification.py and it can't import things from auto_LiRPA:

        9 import torch.nn as nn
       10 import torchvision
  ---> 11 from auto_LiRPA import BoundedModule, BoundedTensor
       12 from auto_LiRPA.perturbations import PerturbationLpNorm
       13 from auto_LiRPA.utils import Flatten

  ImportError: cannot import name 'BoundedModule' from 'auto_LiRPA' (unknown location)

But I can import auto_LiRPA by itself like this:

import auto_LiRPA (succeeds)

I see that BoundedModule is defined in alpha-beta-CROWN\auto_LiRPA\auto_LiRPA\bound_general.py

Is there further setup that I need to do?

Thanks

shizhouxing commented 6 months ago

@mathisdon Are you running the example from the auto_LiRPA/examples folder (is your current working directory auto_LiRPA/examples)?

mathisdon commented 6 months ago

@mathisdon Are you running the example from the auto_LiRPA/examples folder (is your current working directory auto_LiRPA/examples)?

No I wasn't. I'll try that now.

mathisdon commented 6 months ago

That worked when I CD'd to the examples/vision directory and ran it from there like this:

python -m simple_verification

Thanks! I don't fully understand the semantics of python modules so I don't know why it had to be run from what looks like inside the auto_LiRPA module.

One last question: Is there a way to run it inside a Jupyter Notebook other than doing the following?

!python -m simple_verification

(By the way, it could not find simple_verification when I tried it in the examples directory. I had to go down into the examples/vision directory where the file lives.)

shizhouxing commented 6 months ago

I don't fully understand the semantics of python modules so I don't know why it had to be run from what looks like inside the auto_LiRPA module

If you are at the alpha-beta-CROWN directory, it will try to import auto_LiRPA locally from alpha-beta-CROWN/auto_LiRPA (due to the existence of an auto_LiRPA directory there), but actually we need to import from alpha-beta-CROWN/auto_LiRPA/auto_LiRPA.

And when you are at auto_LiRPA/examples, it will import auto_LiRPA from the installed module, because there is no auto_LiRPA folder within the examples folder, so it can work.

One last question: Is there a way to run it inside a Jupyter Notebook other than doing the following?

That's possible. You may need to copy the code to a notebook.

mathisdon commented 6 months ago

Ah of course, I see that now. The outer auto_LiRPA directory is not a module because it has no init.py file. But the inner auto_LiRPA does. And so examples/ is not inside the module, it's just inside the outer auto_LiRPA directory. Thanks.

Actually , I still don't understand how the python file inside the examples/vision directory knows about the auto_LiRPA module which is 2 levels up the file hierarchy... :/

shizhouxing commented 6 months ago

Actually , I still don't understand how the python file inside the examples/vision directory knows about the auto_LiRPA module which is 2 level up the file hierarchy... :/

Because you have installed auto_LiRPA by running pip install . as instructed in the auto_LiRPA's installation guide. After that, you can import auto_LiRPA anywhere, just like you can import pytorch anywhere.

mathisdon commented 6 months ago

Ok, yes. Thanks for your patience with this elementary stuff, I greatly appreciate the help! I can probably take it from here.