mirror of https://github.com/davisking/dlib.git
* Hold on to the CUDA buffer - second try see: https://github.com/davisking/dlib/pull/1855#discussion_r314666348 * Fix #1849 by calling device_global_buffer() unconditionally
This commit is contained in:
parent
b02be8c734
commit
d7fb51e60b
|
@ -438,16 +438,12 @@ namespace dlib
|
|||
const size_t bytes_per_plane = subnetwork_output.nr()*subnetwork_output.nc()*sizeof(uint16_t);
|
||||
// Allocate a cuda buffer to store all the truth images and also one float
|
||||
// for the scalar loss output.
|
||||
if (!work)
|
||||
{
|
||||
work = device_global_buffer();
|
||||
}
|
||||
cuda_data_void_ptr buf = work->get(subnetwork_output.num_samples()*bytes_per_plane + sizeof(float));
|
||||
work = device_global_buffer();
|
||||
buf = work->get(subnetwork_output.num_samples()*bytes_per_plane + sizeof(float));
|
||||
|
||||
cuda_data_void_ptr loss_buf = buf;
|
||||
buf = buf+sizeof(float);
|
||||
|
||||
|
||||
// copy the truth data into a cuda buffer.
|
||||
for (long i = 0; i < subnetwork_output.num_samples(); ++i, ++truth)
|
||||
{
|
||||
|
@ -471,6 +467,7 @@ namespace dlib
|
|||
);
|
||||
|
||||
mutable std::shared_ptr<resizable_cuda_buffer> work;
|
||||
mutable cuda_data_void_ptr buf;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue