devices[0] is not the CPU
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 701
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
There is a misleading comment in the code:
```
extern std::vector devices; // [0] is always the CPU
```
( here: https://github.com/clab/dynet/blob/master/dynet/dynet.h#L49 )
It seems that this is not true. If I check what type is devices[0] with the following code:
```
#include
#include "dynet/dynet.h"
#include "dynet/devices.h"
int main(int argc, char* argv[])
{
dynet::initialize(argc, argv);
auto dd = dynet::default_device;
std::cout << "default: " << (dd->type == dynet::DeviceType::GPU ? "GPU" : "CPU") << std::endl;
auto d0 = dynet::get_device_manager()->get_devices().at(0u);
std::cout << "type: " << (d0->type == dynet::DeviceType::GPU ? "GPU" : "CPU") << std::endl;
}
```
I have the following output no matter if I specify devices with the `--dynet-devices` argument.
```
default: GPU
type: GPU
```
Is the comment outdated or is this (minor) a bug?
If the comment is outdate, it would be nice to have a global variable pointing to the cpu device (similar to dynet::default_device).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.