NREL / EvoProtGrad

Directed evolution of proteins in sequence space with gradients
https://nrel.github.io/EvoProtGrad/
BSD 3-Clause "New" or "Revised" License
45 stars 7 forks source link

Error in demo.ipynb #1

Closed Amelie-Schreiber closed 10 months ago

Amelie-Schreiber commented 11 months ago

When running the second cell:

# HuggingFace ESM2 8M model
esm2_expert = evo_prot_grad.get_expert('esm', temperature = 1.0, device = 'cuda')

# Supervised fluorescence regression model
gfp_expert = evo_prot_grad.get_expert(
                        'onehot_downstream_regression',
                        temperature = 1.0,
                        model = AutoModel.from_pretrained('NREL/avGFP-fluorescence-onehot-cnn',trust_remote_code=True),
                        device = 'cuda')

variants, scores = evo_prot_grad.DirectedEvolution(
                        wt_fasta = 'test/gfp.fasta',
                        output = 'all',
                        experts = [esm2_expert, gfp_expert],
                        parallel_chains = 16,
                        n_steps = 1000,              
                        max_mutations = 15,
                        verbose = False
)()

I get the following error:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
File [~/vscode_projects/proteins/EvoProtGrad/evo_prot_grad/__init__.py:54](https://file+.vscode-resource.vscode-cdn.net/Users/amelieschreiber/vscode_projects/proteins/EvoProtGrad/~/vscode_projects/proteins/EvoProtGrad/evo_prot_grad/__init__.py:54), in get_expert(expert_name, temperature, model, tokenizer, device, use_without_wildtype)
     53     expert_mod = importlib.import_module(f"evo_prot_grad.experts.{expert_name}_expert")
---> 54     return expert_mod.build(
     55         temperature = temperature,
     56         model = model,
     57         tokenizer = tokenizer,
     58         device = device,
     59         use_without_wildtype = use_without_wildtype
     60     )
     61 except:

File [~/vscode_projects/proteins/EvoProtGrad/evo_prot_grad/experts/esm_expert.py:65](https://file+.vscode-resource.vscode-cdn.net/Users/amelieschreiber/vscode_projects/proteins/EvoProtGrad/~/vscode_projects/proteins/EvoProtGrad/evo_prot_grad/experts/esm_expert.py:65), in build(**kwargs)
     64 """Builds a Esm2Expert."""
---> 65 return EsmExpert(**kwargs)

File [~/vscode_projects/proteins/EvoProtGrad/evo_prot_grad/experts/esm_expert.py:38](https://file+.vscode-resource.vscode-cdn.net/Users/amelieschreiber/vscode_projects/proteins/EvoProtGrad/~/vscode_projects/proteins/EvoProtGrad/evo_prot_grad/experts/esm_expert.py:38), in EsmExpert.__init__(self, temperature, model, tokenizer, device, use_without_wildtype)
     37     raise ValueError("EsmExpert requires both `model` and `tokenizer` to be specified.")
---> 38 super().__init__(
     39     temperature,
     40     model,
     41     tokenizer.get_vocab(),
     42     device,
     43     use_without_wildtype)
...
     60     )
     61 except:
---> 62     raise ValueError(f"Expert {expert_name} not found in evo_prot_grad.experts.")

ValueError: Expert esm not found in evo_prot_grad.experts.
pemami4911 commented 10 months ago

Hi! Is PyTorch installed with cuda on your machine? If not, this could be causing this exception.

I've pushed an update to the branch dev to improve error messaging here. Installing the package in editable mode from the dev branch should help trace the issue:

git clone https://github.com/NREL/EvoProtGrad.git
cd EvoProtGrad
git checkout dev
pip install -e .
pemami4911 commented 10 months ago

Hi @Amelie-Schreiber Please let me know if your error has been resolved, otherwise I will go ahead and close this Issue soon.

Amelie-Schreiber commented 10 months ago

Hi, sorry for the delay. You can close the issue.

On Fri, Sep 15, 2023 at 6:07 AM Patrick Emami @.***> wrote:

Hi @Amelie-Schreiber https://github.com/Amelie-Schreiber Please let me know if your error has been resolved, otherwise I will go ahead and close this Issue soon.

— Reply to this email directly, view it on GitHub https://github.com/NREL/EvoProtGrad/issues/1#issuecomment-1721254680, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMIK6IFONM23353AQIG7HODX2RHKFANCNFSM6AAAAAA4FOR6FE . You are receiving this because you were mentioned.Message ID: @.***>

pemami4911 commented 10 months ago

Thanks!