Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying the code/run_optiprompt.py #1

Closed
Luciferder opened this issue Jun 22, 2021 · 1 comment
Closed

Error when trying the code/run_optiprompt.py #1

Luciferder opened this issue Jun 22, 2021 · 1 comment

Comments

@Luciferder
Copy link

I tried your command template as follow:
#################################
rel=P101
dir=outputs/${rel}
mkdir -p ${dir}

python code/run_optiprompt.py
--relation_profile relation_metainfo/LAMA_relations.jsonl
--relation ${rel}
--common_vocab_filename common_vocabs/common_vocab_cased.txt
--model_name bert-base-cased
--do_train
--train_data data/autoprompt_data/${rel}/train.jsonl
--dev_data data/autoprompt_data/${rel}/dev.jsonl
--do_eval
--test_data data/LAMA-TREx/${rel}.jsonl
--output_dir ${dir}
--random_init none
--output_predictions
#################################
However, an error was given as follow:

#########################
Traceback (most recent call last):
File "code/run_optiprompt.py", line 174, in
best_result, result_rel = evaluate(model, valid_samples_batches, valid_sentences_batches, filter_indices, index_list)
File "/home/prompt/OptiPrompt/code/utils.py", line 133, in evaluate
eval_loss += loss.item() * tot_b
ValueError: only one element tensors can be converted to Python scalars
##########################

How can I sovle it? Thanks~

@a3616001
Copy link
Member

Hi, thanks for your interest!

How many GPUs are you using?
Could you try with single GPU (e.g., adding CUDA_VISIBLE_DEVICES=0 before the command)?

@a3616001 a3616001 closed this as completed Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants