No type found for Optimizer attribute error
❓ Questions and Help
I have been trying to run the hateful memes project - specifically the ViLBERT CC model and am getting this error. I ran the following command as suggested in the readme here:
mmf_run config=projects/hateful_memes/configs/vilbert/from_cc.yaml model=vilbert dataset=hateful_memes run_type=val
But I keep getting the following error:
2020-06-05 06:31:11.441134: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
Namespace(config_override=None, local_rank=None, opts=['config=projects/hateful_memes/configs/vilbert/from_cc.yaml', 'model=vilbert', 'dataset=hateful_memes', 'run_type=val'])
/usr/local/lib/python3.6/dist-packages/omegaconf/dictconfig.py:252: UserWarning: Keys with dot (../../../vilbert/configs/hateful_memes/from_cc.yaml) are deprecated and will have different semantic meaning the next major version of OmegaConf (2.1)
See the compact keys issue for more details: https://github.com/omry/omegaconf/issues/152
You can disable this warning by setting the environment variable OC_DISABLE_DOT_ACCESS_WARNING=1
warnings.warn(message=msg, category=UserWarning)
Overriding option config to projects/hateful_memes/configs/vilbert/from_cc.yaml
Overriding option model to vilbert
Overriding option datasets to hateful_memes
Overriding option run_type to val
Using seed 14231137
Logging to: ./save/logs/train_2020-06-05T06:31:14.log
Downloading extras.tar.gz: 100% 211k/211k [00:01<00:00, 148kB/s]
/root/.cache/torch/mmf/glove.6B.zip: 862MB [06:30, 2.21MB/s]
100% 399194/400000 [01:00<00:00, 8306.14it/s]Traceback (most recent call last):
File "/usr/local/bin/mmf_run", line 11, in <module>
load_entry_point('mmf', 'console_scripts', 'mmf_run')()
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf_cli/run.py", line 91, in run
main(configuration, predict=predict)
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf_cli/run.py", line 38, in main
trainer.load()
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf/trainers/base_trainer.py", line 60, in load
self.load_model_and_optimizer()
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf/trainers/base_trainer.py", line 123, in load_model_and_optimizer
self.optimizer = build_optimizer(self.model, self.config)
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf/utils/build.py", line 186, in build_optimizer
"Optimizer attributes must have a 'type' key "
ValueError: Optimizer attributes must have a 'type' key specifying the type of optimizer. (Custom or PyTorch)
100% 399194/400000 [01:32<00:00, 4332.44it/s]
Thanks in advance!
Can you run this exact command again with but with added parameter of training.log_detailed_config=True at the end?
So run:
mmf_run config=projects/hateful_memes/configs/vilbert/from_cc.yaml model=vilbert dataset=hateful_memes run_type=val training.log_detailed_config=True
and post back the stdout here.
Actually, while you do this, can you also run python -m torch.utils.collect_env and post output here.
@apsdehal Okay sure, will do that and post.
output for the command with training.log_detailed=True
2020-06-05 08:26:52.928357: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
Namespace(config_override=None, local_rank=None, opts=['config=projects/hateful_memes/configs/vilbert/from_cc.yaml', 'model=vilbert', 'dataset=hateful_memes', 'run_type=val', 'training.log_detailed_config=True'])
/usr/local/lib/python3.6/dist-packages/omegaconf/dictconfig.py:252: UserWarning: Keys with dot (../../../vilbert/configs/hateful_memes/from_cc.yaml) are deprecated and will have different semantic meaning the next major version of OmegaConf (2.1)
See the compact keys issue for more details: https://github.com/omry/omegaconf/issues/152
You can disable this warning by setting the environment variable OC_DISABLE_DOT_ACCESS_WARNING=1
warnings.warn(message=msg, category=UserWarning)
Overriding option config to projects/hateful_memes/configs/vilbert/from_cc.yaml
Overriding option model to vilbert
Overriding option datasets to hateful_memes
Overriding option run_type to val
Overriding option training.log_detailed_config to True
Using seed 59365811
Logging to: ./save/logs/train_2020-06-05T08:26:59.log
Downloading extras.tar.gz: 100% 211k/211k [00:01<00:00, 142kB/s]
/root/.cache/torch/mmf/glove.6B.zip: 862MB [06:30, 2.21MB/s]
100% 399493/400000 [01:10<00:00, 8083.07it/s]Traceback (most recent call last):
File "/usr/local/bin/mmf_run", line 11, in <module>
load_entry_point('mmf', 'console_scripts', 'mmf_run')()
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf_cli/run.py", line 91, in run
main(configuration, predict=predict)
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf_cli/run.py", line 38, in main
trainer.load()
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf/trainers/base_trainer.py", line 60, in load
self.load_model_and_optimizer()
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf/trainers/base_trainer.py", line 123, in load_model_and_optimizer
self.optimizer = build_optimizer(self.model, self.config)
File "/content/drive/My Drive/MPL_hatefulmemes/mmf/mmf/utils/build.py", line 186, in build_optimizer
"Optimizer attributes must have a 'type' key "
ValueError: Optimizer attributes must have a 'type' key specifying the type of optimizer. (Custom or PyTorch)
100% 399493/400000 [01:35<00:00, 4198.27it/s]
Output for python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.5.0+cu101
Is debug build: No
CUDA used to build PyTorch: 10.1
OS: Ubuntu 18.04.3 LTS
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
CMake version: version 3.12.0
Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 10.1.243
GPU models and configuration: GPU 0: Tesla K80
Nvidia driver version: 418.67
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
Versions of relevant libraries:
[pip3] numpy==1.16.6
[pip3] torch==1.5.0+cu101
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.5.0
[pip3] torchvision==0.6.0+cu101
[conda] Could not collect
Have you installed from source or pip package?
I installed from source using these commands
git clone https://github.com/facebookresearch/mmf.git
cd mmf
pip install --editable .
This was the complete log for that command: Is there a way to work around this issue?
2020-06-06T05:29:34 | INFO | mmf.train : ===== Training Parameters =====
2020-06-06T05:29:34 | INFO | mmf.train : {
"batch_size": 512,
"checkpoint_interval": 1000,
"clip_gradients": false,
"clip_norm_mode": "all",
"dataset_size_proportional_sampling": true,
"device": "cuda",
"early_stop": {
"criteria": "total_loss",
"enabled": false,
"minimize": true,
"patience": 4000
},
"evaluate_metrics": false,
"evaluation_interval": 1000,
"experiment_name": "run",
"fast_read": false,
"find_unused_parameters": false,
"local_rank": null,
"log_detailed_config": true,
"log_format": "simple",
"log_interval": 100,
"logger_level": "info",
"lr_ratio": 0.1,
"lr_scheduler": false,
"lr_steps": [],
"max_epochs": null,
"max_updates": 22000,
"num_workers": 4,
"pin_memory": false,
"seed": 34185610,
"should_not_log": false,
"stdout_capture": true,
"tensorboard": false,
"trainer": "base_trainer",
"use_warmup": false,
"verbose_dump": false,
"warmup_factor": 0.2,
"warmup_iterations": 1000
}
2020-06-06T05:29:34 | INFO | mmf.train : ====== Dataset Attributes ======
2020-06-06T05:29:34 | INFO | mmf.train : ======== hateful_memes =======
2020-06-06T05:29:34 | INFO | mmf.train : {
"annotations": {
"test": [
"hateful_memes/defaults/annotations/test.jsonl"
],
"train": [
"hateful_memes/defaults/annotations/train.jsonl"
],
"val": [
"hateful_memes/defaults/annotations/dev.jsonl"
]
},
"data_dir": "/root/.cache/torch/mmf/data/datasets",
"depth_first": false,
"fast_read": false,
"features": {
"test": [
"hateful_memes/defaults/features/detectron.lmdb"
],
"train": [
"hateful_memes/defaults/features/detectron.lmdb"
],
"val": [
"hateful_memes/defaults/features/detectron.lmdb"
]
},
"images": {
"test": [
"hateful_memes/defaults/images/"
],
"train": [
"hateful_memes/defaults/images/"
],
"val": [
"hateful_memes/defaults/images/"
]
},
"max_features": 100,
"processors": {
"bbox_processor": {
"params": {
"max_length": 50
},
"type": "bbox"
},
"image_processor": {
"params": {
"transforms": [
{
"params": {
"size": [
256,
256
]
},
"type": "Resize"
},
{
"params": {
"size": [
224,
224
]
},
"type": "CenterCrop"
},
"ToTensor",
"GrayScaleTo3Channels",
{
"params": {
"mean": [
0.46777044,
0.44531429,
0.40661017
],
"std": [
0.12221994,
0.12145835,
0.14380469
]
},
"type": "Normalize"
}
]
},
"type": "torchvision_transforms"
},
"text_processor": {
"params": {
"max_length": 14,
"preprocessor": {
"params": {},
"type": "simple_sentence"
},
"vocab": {
"embedding_name": "glove.6B.300d",
"type": "intersected",
"vocab_file": "hateful_memes/defaults/extras/vocabs/vocabulary_100k.txt"
}
},
"type": "vocab"
}
},
"return_features_info": false,
"use_features": false,
"use_images": true
}
2020-06-06T05:29:34 | INFO | mmf.train : ====== Optimizer Attributes ======
2020-06-06T05:29:34 | INFO | mmf.train : {}
2020-06-06T05:29:34 | INFO | mmf.train : ====== Model (vilbert) Attributes ======
2020-06-06T05:29:34 | INFO | mmf.train : {
"attention_probs_dropout_prob": 0.1,
"bert_model_name": "bert-base-uncased",
"bi_attention_type": 1,
"bi_hidden_size": 1024,
"bi_intermediate_size": 1024,
"bi_num_attention_heads": 8,
"bypass_transformer": false,
"cut_first": "text",
"dynamic_attention": false,
"embedding_strategy": "plain",
"fast_mode": false,
"finetune_lr_multiplier": 1,
"fixed_t_layer": 0,
"fixed_v_layer": 0,
"freeze_base": false,
"fusion_method": "mul",
"hard_cap_seq_len": null,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"hidden_size": 768,
"in_batch_pairs": false,
"initializer_range": 0.02,
"intermediate_size": 3072,
"layer_norm_eps": 1e-12,
"max_position_embeddings": 512,
"model": "bert",
"num_attention_heads": 12,
"num_hidden_layers": 12,
"num_negative": 128,
"objective": 0,
"output_attentions": false,
"output_hidden_states": false,
"pooling_method": "mul",
"random_initialize": false,
"special_visual_initialize": true,
"t_biattention_id": [
6,
7,
8,
9,
10,
11
],
"task_specific_tokens": false,
"text_only": false,
"training_head_type": "pretraining",
"type_vocab_size": 2,
"v_attention_probs_dropout_prob": 0.1,
"v_biattention_id": [
0,
1,
2,
3,
4,
5
],
"v_feature_size": 2048,
"v_hidden_act": "gelu",
"v_hidden_dropout_prob": 0.1,
"v_hidden_size": 1024,
"v_initializer_range": 0.02,
"v_intermediate_size": 1024,
"v_num_attention_heads": 8,
"v_num_hidden_layers": 6,
"v_target_size": 1601,
"visual_embedding_dim": 2048,
"visual_target": 0,
"visualization": false,
"vocab_size": 30522,
"with_coattention": true
}
2020-06-06T05:29:34 | INFO | mmf.train : Loading datasets
2020-06-06T05:29:40 | WARNING | py.warnings : /content/drive/My Drive/MPL_hatefulmemes/mmf/mmf/models/base_model.py:97: UserWarning: No losses are defined in model configuration. You are expected to return loss in your return dict from forward.
"No losses are defined in model configuration. You are expected "
2020-06-06T05:29:40 | INFO | mmf.train : CUDA Device 0 is: Tesla P4
I am unable to reproduce this locally. As far as I can tell, the config file: projects/hateful_memes/configs/vilbert/from_cc.yaml isn't a symlink for you.
Test the output of
file projects/hateful_memes/configs/vilbert/from_cc.yaml to see whether it is a symlink or not. If that's the case, I am not sure why would that often.
A workaround for now is to copy the original file i.e. projects/vilbert/configs/hateful_memes/from_cc.yaml directly to projects/hateful_memes/configs/vilbert/from_cc.yaml so that symlink situation is resolved.
If possible, can you provide me a colab where you can reproduce this issue?
This is the colab notebook that I am working out. The section "Responding to issue on github" reproduces this issue. Also, this is my first time working on colab, so let me know if I shared it the wrong way. Thanks!
Being on colab I am unable to test this.
Test the output of
file projects/hateful_memes/configs/vilbert/from_cc.yamlto see whether it is a symlink or not. If that's the case, I am not sure why would that often.
I guess this does seem to be an issue. Copying the file from vilbert direcctory doesn't seem to solve the problem since that to is a symlink.
A workaround for now is to copy the original file i.e.
projects/vilbert/configs/hateful_memes/from_cc.yamldirectly toprojects/hateful_memes/configs/vilbert/from_cc.yamlso that symlink situation is resolved.
I have been unable to replicate your issue even on the colab you provided by running it directly. See https://colab.research.google.com/drive/1_JQ4FIiB6u8gPWD5ExKR_BzYTu9RRQ1n. For now solution would be replace the content of the config file you are using with
config_version: 1.0
training:
trainer: base_trainer
seed: 544559
experiment_name: run
max_updates: 22000
max_epochs: null
log_interval: 100
logger_level: info
log_format: simple
log_detailed_config: false
should_not_log: false
stdout_capture: true
tensorboard: false
batch_size: 32
num_workers: 4
fast_read: false
dataset_size_proportional_sampling: true
pin_memory: false
checkpoint_interval: 1000
evaluation_interval: 1000
clip_gradients: false
clip_norm_mode: all
early_stop:
enabled: false
patience: 4000
criteria: hateful_memes/roc_auc
minimize: false
lr_scheduler: true
lr_steps: []
lr_ratio: 0.1
use_warmup: false
warmup_factor: 0.2
warmup_iterations: 1000
device: cuda
local_rank: null
verbose_dump: false
find_unused_parameters: true
evaluate_metrics: false
evaluation:
metrics:
- accuracy
- binary_f1
- roc_auc
predict: false
predict_file_format: csv
model_config:
vilbert:
bert_model_name: bert-base-uncased
training_head_type: classification
visual_embedding_dim: 2048
special_visual_initialize: true
hard_cap_seq_len: null
cut_first: text
embedding_strategy: plain
bypass_transformer: false
output_attentions: false
output_hidden_states: false
text_only: false
random_initialize: false
freeze_base: false
finetune_lr_multiplier: 1
attention_probs_dropout_prob: 0.1
layer_norm_eps: 1.0e-12
hidden_act: gelu
hidden_dropout_prob: 0.1
hidden_size: 768
initializer_range: 0.02
intermediate_size: 3072
max_position_embeddings: 512
num_attention_heads: 12
num_hidden_layers: 12
type_vocab_size: 2
vocab_size: 30522
v_feature_size: 2048
v_target_size: 1601
v_hidden_size: 1024
v_num_hidden_layers: 6
v_num_attention_heads: 8
v_intermediate_size: 1024
bi_hidden_size: 1024
bi_num_attention_heads: 8
bi_intermediate_size: 1024
bi_attention_type: 1
v_attention_probs_dropout_prob: 0.1
v_hidden_act: gelu
v_hidden_dropout_prob: 0.1
v_initializer_range: 0.02
v_biattention_id:
- 0
- 1
- 2
- 3
- 4
- 5
t_biattention_id:
- 6
- 7
- 8
- 9
- 10
- 11
pooling_method: mul
fusion_method: mul
fast_mode: false
with_coattention: true
dynamic_attention: false
in_batch_pairs: false
task_specific_tokens: false
fixed_v_layer: 0
fixed_t_layer: 0
visualization: false
visual_target: 0
objective: 0
num_negative: 128
model: vilbert
num_labels: 2
losses:
- cross_entropy
dataset_config:
hateful_memes:
data_dir: ${env.data_dir}/datasets
depth_first: false
fast_read: false
use_images: false
use_features: true
images:
train:
- hateful_memes/defaults/images/
val:
- hateful_memes/defaults/images/
test:
- hateful_memes/defaults/images/
features:
train:
- hateful_memes/defaults/features/detectron.lmdb
val:
- hateful_memes/defaults/features/detectron.lmdb
test:
- hateful_memes/defaults/features/detectron.lmdb
annotations:
train:
- hateful_memes/defaults/annotations/train.jsonl
val:
- hateful_memes/defaults/annotations/dev.jsonl
test:
- hateful_memes/defaults/annotations/test.jsonl
max_features: 100
processors:
text_processor:
type: bert_tokenizer
params:
max_length: 14
vocab:
type: intersected
embedding_name: glove.6B.300d
vocab_file: hateful_memes/defaults/extras/vocabs/vocabulary_100k.txt
preprocessor:
type: simple_sentence
params: {}
tokenizer_config:
type: bert-base-uncased
params:
do_lower_case: true
mask_probability: 0
max_seq_length: 128
bbox_processor:
type: bbox
params:
max_length: 50
image_processor:
type: torchvision_transforms
params:
transforms:
- type: Resize
params:
size:
- 256
- 256
- type: CenterCrop
params:
size:
- 224
- 224
- ToTensor
- GrayScaleTo3Channels
- type: Normalize
params:
mean:
- 0.46777044
- 0.44531429
- 0.40661017
std:
- 0.12221994
- 0.12145835
- 0.14380469
return_features_info: true
optimizer:
type: adam_w
params:
lr: 1.0e-05
eps: 1.0e-08
scheduler:
type: warmup_linear
params:
num_warmup_steps: 2000
num_training_steps: 22000
I will try to look into more why this issue might be happening. For long term, I will open up a task to move away from symlinks and use includes instead.
@agam-kashyap Can you check and tell me what is your filesystem type (e.g. Fat/ntfs etc.)?
Also, can you provide me the value of git config -l | grep symlinks inside your repository?
@apsdehal I am working on Google Colab, so I am not sure of what file system they use. The output of that command over there came as
core.symlinks=false
OK that seems like the issue. Can you clone the repo again with command:
git clone --config core.symlinks=true https://github.com/facebookresearch/mmf.git and try your commands again?
Yes, I did that, but I got this error
error: unable to create symlink mmf/projects: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/concat_bert/defaults.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/concat_bow/defaults.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/late_fusion/defaults.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/mmbt/defaults.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/mmbt/with_features.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/unimodal/bert.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/unimodal/image.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/unimodal/text.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/unimodal/with_features.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/vilbert/defaults.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/vilbert/direct.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/vilbert/from_cc.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/visual_bert/defaults.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/visual_bert/direct.yaml: Operation not supported
error: unable to create symlink projects/hateful_memes/configs/visual_bert/from_coco.yaml: Operation not supported
error: unable to create symlink projects/m4c_captioner/configs/butd/textcaps: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/vilbert/masked_coco/defaults.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/vilbert/masked_coco/full.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/vilbert/masked_conceptual_captions/defaults.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/vilbert/masked_conceptual_captions/full.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/vilbert/masked_vqa2/defaults.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/vilbert/masked_vqa2/full.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/visual_bert/masked_coco/defaults.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/visual_bert/masked_coco/full.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/visual_bert/masked_coco/full_train_val.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/visual_bert/masked_conceptual_captions/defaults.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/visual_bert/masked_conceptual_captions/full.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/visual_bert/masked_vqa2/defaults.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/visual_bert/masked_vqa2/full.yaml: Operation not supported
error: unable to create symlink projects/pretrain_vl_right/configs/visual_bert/masked_vqa2/full_train_val.yaml: Operation not supported
Checking out files: 100% (498/498), done.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
As per https://github.com/alicevision/meshroom/issues/735, this happens when your google drive is not properly mounted. Can you follow the conversation and steps in that issue to see if that fixes your problem? As with meshroom, this problem is more related to colab rather than mmf.
We will also open up a PR on our end to fix this properly by removing all symlinks.
Also, if possible try using colab's internal storage instead of your Google Drive. For e.g. clone mmf directly in /content/.
Sure. I will look into that thread and try using the internal storage itself. Thanks a lot for your help!
Same thing can happen on Windows. Now that I know about symlinks, I cloned the repository with care using this SO answer