fixed bug where CPU has less memory than GPU causing NULL malloc