endernewton / c2board

Tensorboard for Caffe2
MIT License
33 stars 6 forks source link

AttributeError: 'DeviceOption' object has no attribute 'cuda_gpu_id' #4

Open zhonhel opened 6 years ago

zhonhel commented 6 years ago

Hi, Thank you very much for providing this tool. But I encountered error when using writer.write_graph this function. And the argument I provided to it is a DetectionModelHelper(from the Facebook detectron repo) class object, which is a subclass of cnn.CNNModelHelper. But I got the error:

  File "~/c2board/c2board/writer.py", line 229, in write_graph
    current_graph, track_blob_names = model_to_graph(model_or_nets_or_protos, **kwargs)

  File "~/c2board/c2board/graph.py", line 376, in model_to_graph
    return nets_to_graph(nets, **kwargs)

  File "~/c2board/c2board/graph.py", line 381, in nets_to_graph
    return protos_to_graph(nets, **kwargs)

  File "~/c2board/c2board/graph.py", line 388, in protos_to_graph
    return _operators_to_graph_def(ops, **kwargs)

  File "~/c2board/c2board/graph.py", line 369, in _operators_to_graph_def
    current_graph.node.extend(_operator_to_node(op, inter_blobs, seen))

  File "~/c2board/c2board/graph.py", line 229, in _operator_to_node
    n.device = _tf_device(op.device_option)

  File "~/c2board/c2board/graph.py", line 171, in _tf_device
    return "/gpu:{}".format(device_option.cuda_gpu_id)

AttributeError: 'DeviceOption' object has no attribute 'cuda_gpu_id'
csgcmai commented 5 years ago

Hi @zhonhel, you may like to change the code as the following

index 88cb83e..22e7c12 100644 --- a/c2board/graph.py +++ b/c2board/graph.py @@ -168,7 +168,7 @@ def _tf_device(device_option): if device_option.device_type == caffe2_pb2.CPU: return "/cpu:*" if device_option.device_type == caffe2_pb2.CUDA: - return "/gpu:{}".format(device_option.cuda_gpu_id) + return "/gpu:{}".format(device_option.device_id) raise Exception("Un-handled device", device_option)