getnamo / TensorFlow-Unreal

TensorFlow plugin for the Unreal Engine.
Other
1.15k stars 211 forks source link

Support for 4.18 #15

Closed Umax1004 closed 6 years ago

Umax1004 commented 6 years ago

Error while building. in TensorFlow.cpp the IsAvailable() and Get() do not exist in FUnrealEnginePythonModule if (FUnrealEnginePythonModule::IsAvailable()) { FUnrealEnginePythonModule::Get().AddPythonDependentPlugin("TensorFlow"); } else { UE_LOG(TensorFlowLog, Warning, TEXT("UnrealEnginePython Plugin not found! Make sure you've enabled it in Edit->Plugins.")); }

getnamo commented 6 years ago

4.18 has a fair amount of changes and I just merged the upstream unrealenginepython plugin recently: https://github.com/getnamo/UnrealEnginePython/commits/master (which this plugin depends on) and SIOJson module from socketio plugin (https://github.com/getnamo/socketio-client-ue4/commits/master)

But something broke with pip/directories lookup. Will look at getting 4.18 support fully working ~next week or two.

corneel commented 6 years ago

Has this compile issue been resolved? I am getting: Severity Code Description Project File Line Suppression State Error C2039 'IsAvailable': is not a member of 'FUnrealEnginePythonModule' Tensorflow418 C:\Users\corne\Documents\Unreal Projects\Tensorflow418\Plugins\tensorflow-ue4\Source\TensorFlow\Private\TensorFlow.cpp 16

Environment is Unreal 4.18.1

getnamo commented 6 years ago

Still on the docket, haven't found any open source hours to address this yet. Something in my python fork updates: https://github.com/getnamo/UnrealEnginePython/commit/3319e0a01980f5b6efa22d69e582a51068106d3c and https://github.com/getnamo/UnrealEnginePython/commit/8a8a770b99e89afac2b4d02b23b7b086cab2a826 broke pip fetching. If you pull all 3 master branches of the dependent plugins you will get a version that compiles, but which won't pull tensorflow python modules correctly at this time. It should work if you manually pull the dependencies though.

corneel commented 6 years ago

Yes so I looked at the whole history of FUnrealEnginePythonModule and it has never had those methods. I was just about to go look at the history of TensorFlow.cpp to see if it has changed recently.

corneel commented 6 years ago

How can I manually pull the dependencies?

corneel commented 6 years ago

The way the modules in the Unreal Python libraries check that the other modules are enabled is by using the Unreal IPluginManager class, method GetEnabledPlugins:

https://docs.unrealengine.com/latest/INT/API/Runtime/Projects/Interfaces/IPluginManager/GetEnabledPlugins/index.html

getnamo commented 6 years ago

in your {project root}/Plugins folder add https://github.com/getnamo/UnrealEnginePython and https://github.com/getnamo/socketio-client-ue4 and this plugin as git clones. See e.g. https://github.com/getnamo/tensorflow-ue4-examples which uses the plugins as submodules. Note that if you do git clone to a fresh repository you need to ensure you download the python binaries and place them inside the python plugin as instructed here: https://github.com/getnamo/tensorflow-ue4#note-on-git-cloning

Once all the plugins are in place, do a compile on your C++ project to produce the plugin dlls and you should then be able to pull python wheels manually via pip found under /Plugins/UnrealEnginePython/Binaries/Win64/Scripts This can be run under command line e.g. pip install tensorflow-gpu

corneel commented 6 years ago

Ok I just compared the fork with the standard UnrealPython and there it definitely had this member: static inline FUnrealEnginePythonModule& Get() { return FModuleManager::LoadModuleChecked< FUnrealEnginePythonModule >("UnrealEnginePython"); }

So I searched for FModuleManager and I see the other modules in the main branch still use that method internally. I am going to see if there is a way to just execute the code ourselves.

corneel commented 6 years ago

Ahh, you know what that is Unreal code so you could potentially just include ModuleManager.h and execute the code. I don't know your code well enough so I will leave that to you to decide. Thanks for the advice, I hope I helped a bit.

corneel commented 6 years ago

For completeness, this is how other modules in the main branch do it:

void UPythonBlueprintFunctionLibrary::ExecutePythonScript(FString script) { FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); PythonModule.RunFile(TCHAR_TO_UTF8(*script)); }

...or here is another one. void UPythonScript::Run() { FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); PythonModule.RunFile(TCHAR_TO_UTF8(*ScriptPath)); if (!FunctionToCall.IsEmpty()) { CallSpecificFunctionWithArgs(); } }

getnamo commented 6 years ago

I'll keep this in mind when I do the fix, it may very well be the missing bit.

corneel commented 6 years ago

I got it compiled but the “missing tensorflow” module message would not go away.

Some threads on the internet seems to think it has something to do with anaconda.

Sent from my iPhone

On Dec 8, 2017, at 8:50 PM, getnamo notifications@github.com<mailto:notifications@github.com> wrote:

I'll keep this in mind when I do the fix, it may very well be the missing bit.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgetnamo%2Ftensorflow-ue4%2Fissues%2F15%23issuecomment-350418479&data=02%7C01%7C%7Ca65d5f2f1c2840cf23fc08d53eaf9e99%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636483846351948744&sdata=1qxDDFwh4PTaQCb%2BRYpD%2BKcd82PXCYP8RuNmckbgZeY%3D&reserved=0, or mute the threadhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAVw30Zs4DiXyP0qVDdJAx32fMsNhhi_ks5s-fV5gaJpZM4QSWRa&data=02%7C01%7C%7Ca65d5f2f1c2840cf23fc08d53eaf9e99%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636483846351948744&sdata=6hcNV1QGm1orGLfP%2BkoW%2BBTMZDBzQQ%2FNP2gYE7lteQk%3D&reserved=0.

getnamo commented 6 years ago

Finally updated to UE4.18 and tensorflow 1.4. Grab the latest update at https://github.com/getnamo/tensorflow-ue4/releases/tag/0.5.0

There was a bug when I merged upstream which broke the directories I was looking for pip and plugin scripts. Painfully simply fix https://github.com/getnamo/UnrealEnginePython/commit/b79b3739a46ebddd407bc5ed6f570ef81bead249, but now it works :)