caffe2
caffe2 copied to clipboard
Tensor type mismatch, caller expects elements to be float while tensor contains caffe2::__f16 Error from operator
When I run the script resnet50_trainer.py with dtype='float16'
$ python resnet50_trainer.py --train_data="null" --gpus=0 --num_channels=3 --image_size=227 --num_labels=1000 --batch_size=128 --epoch_size=1000 --num_epochs=1 --file_store_path='./' --dtype='float16'
I got the error: Tensor type mismatch, caller expects elements to be float while tensor contains caffe2::__f16 Error from operator: input: "gpu_0/data" input: "gpu_0/conv1_w" output: "gpu_0/conv1" name: "" type: "Conv" arg { name: "kernel" i: 7 } arg { name: "enable_tensor_core" i: 0 } arg { name: "exhaustive_search" i: 1 } arg { name: "stride" i: 2 } arg { name: "pad" i: 3 } arg { name: "order" s: "NCHW" } arg { name: "ws_nbytes_limit" i: 67108864 } device_option { device_type: 1 cuda_gpu_id: 0 } engine: "CUDNN"
Who can help me? thanks!
I met the same problem earlier. It means that your weight value of net is type of float , but the tensor of net is fp16. You can print the weight values such as "conv1_w" and watch the content.
Hi @gjm441 , then how to solve this mismatch issue? Thanks
@hfutxrg Try to use the function "HalfToFloat", converting the net to float instead.
HI @gjm441 @renganxu ,
I have a similar issue but with unsigned char:
RuntimeError: [enforce fail at tensor.h:495] IsType<T>(). Tensor type mismatch, caller expects elements to be float while tensor contains unsigned char Error from operator:
input: "data" input: "conv1__w" input: "conv1__b" output: "conv1_" name: "" type: "Conv" arg { name: "kernel" i: 11 } arg { name: "exhaustive_search" i: 0 } arg { name: "legacy_pad" i: 1 } arg { name: "order" s: "NHWC" } arg { name: "stride" i: 4 } device_option { device_type: 0 cuda_gpu_id: 0 } engine: "CUDNN"
** while accessing input: data
do you have any suggestion on how to solve this issue?